This project is licensed under the MIT license.
This project implements a customizable load balancer using consistent hashing.
- Server: Simple Docker server with
/home
and/heartbeat
endpoints. - Consistent Hashing: Python implementation of consistent hashing.
- Load Balancer: Flask-based load balancer managing server containers.
-
Install
python3
,pip
, andpytest
libraries:$ sudo apt-get update $ sudo apt-get install python3 python3-pip python3-pytest -y $ python3 --version $ pip --version $ pytest --version
-
Install
docker
&docker-compose
packages:$ sudo apt-get install docker -y $ sudo apt-get install ca-certificates curl $ sudo install -m 0755 -d /etc/apt/keyrings $ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc $ sudo chmod a+r /etc/apt/keyrings/docker.asc # Add the repository to Apt sources: $ echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin $ sudo apt-get update
-
Install and configure
git
:$ sudo apt install git $ git --version $ sudo apt update $ git config --global user.name "your-github-username" $ git config --global user.email "your-github-email" $ git config --list
-
Clone or download the repository to your local machine:
$ cd Desktop
$ git clone https://github.com/Dennis-Maigua/DS-Load-Balancer.git
- Build and Run docker images or containers:
$ cd DS-Load-Balancer
$ make all
- Install python dependencies for allowing http requests and plotting graphs:
$ sudo apt-get install python3-aiohttp python3-matplotlib -y
- Run asynchronous requests and plot a bar graph for the load distribution of the responses:
$ cd analysis/scripts
$ python3 async_requests.py
- Add Servers and Measure Load Distribution:
$ python3 incremental_servers.py
- Test Endpoints and Observe Failures:
$ python3 test_endpoints.py
- Compare Different Hash Functions:
$ python3 compare_hash_functions.py
We welcome contributions from developers, IT experts, and technology enthusiasts. Feel free to fork the repository, make improvements, and submit pull requests.