Skip to content

Dennis-Maigua/DS-Load-Balancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT

This project is licensed under the MIT license.

Customizable Load Balancer

Load Balancer

This project implements a customizable load balancer using consistent hashing.

Design

  1. Server: Simple Docker server with /home and /heartbeat endpoints.
  2. Consistent Hashing: Python implementation of consistent hashing.
  3. Load Balancer: Flask-based load balancer managing server containers.

Setup

  1. Install python3, pip, and pytest libraries:

    $ sudo apt-get update
    $ sudo apt-get install python3 python3-pip python3-pytest -y
    $ python3 --version
    $ pip --version
    $ pytest --version
  2. 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
  3. 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
  4. Clone or download the repository to your local machine:

$ cd Desktop
$ git clone https://github.com/Dennis-Maigua/DS-Load-Balancer.git

Testing and Performance

  1. Build and Run docker images or containers:
$ cd DS-Load-Balancer
$ make all

Screenshot from 2024-06-13 13-10-38

  1. Install python dependencies for allowing http requests and plotting graphs:
$ sudo apt-get install python3-aiohttp python3-matplotlib -y
  1. Run asynchronous requests and plot a bar graph for the load distribution of the responses:
$ cd analysis/scripts
$ python3 async_requests.py

Figure_1

  1. Add Servers and Measure Load Distribution:
$ python3 incremental_servers.py
  1. Test Endpoints and Observe Failures:
$ python3 test_endpoints.py
  1. Compare Different Hash Functions:
$ python3 compare_hash_functions.py

Contributing:

We welcome contributions from developers, IT experts, and technology enthusiasts. Feel free to fork the repository, make improvements, and submit pull requests.