This project demonstrates a simple load balancer using Python's built-in libraries. The load balancer uses the Round Robin algorithm to distribute client requests across multiple backend servers. It includes a load balancer, two backend servers, and a test client.
. ├── Makefile ├── README.md ├── client │ └── client.py ├── load_balancer │ └── load_balancer.py ├── requirements.txt ├── server1 │ └── server1.py └── server2 └── server2.py
- Python 3.6 or higher
requests
library
-
Clone the repository:
-
git clone https://github.com/lucasfonsecads/loadbalance-medium-example
-
cd load-balancer-example
-
-
Create and activate the virtual environment, and install dependencies:
make install
Open two separate terminal windows and run each server:
make server1
make server2
In a third terminal window, run the load balancer:
make load_balancer
In a fourth terminal window, run the test client to verify the load balancer:
make test
To run everything together in the same terminal:
make run_all
This command will start both backend servers, the load balancer, and the test client sequentially, all in the same terminal.
To clean the virtual environment:
make clean
- Load Balancer: Distributes client requests using the Round Robin algorithm.
- Backend Servers: Simple HTTP servers that respond with different messages.
- Test Client: Sends requests to the load balancer to verify that requests are being distributed correctly.
If you would like to contribute to this project, please fork the repository and submit a pull request.
This project is licensed under the MIT License.
This README.md file provides an overview of the project, setup instructions, and commands to run the servers, load balancer, and client. It also includes cleanup instructions and information on contributing and licensing.