This project is a custom implementation of a load balancer designed as part of a coding challenge here. The load balancer distributes incoming requests to multiple backend servers based on their health status. Docker is used to manage the load balancer and the backend servers.
- Load balances requests across multiple backend servers.
- Performs health checks on servers and routes traffic only to healthy ones.
- Easy to configure and extend using a
docker-compose.ymlfile. - Command-line interface (CLI) for building, running, and testing using
make. - Supports automated testing of load balancer performance with
curl.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- You need to have Go and Docker installed on your machine.
- Go version 1.15 or later is recommended.
- Docker and Docker Compose should be installed to manage services and containers.
- Make sure
makeis installed to run the commands from the provided Makefile.
Clone the repository to your local machine:
git clone https://github.com/nullsploit01/cc-load-balancer
cd cc-load-balancerYou can build the project using the Makefile, which handles Docker image building for both the backend servers and the load balancer.
make buildOnce the images are built, you can start the load balancer and backend servers using:
make upTo stop the services, use:
make downYou can test the load balancer by making parallel HTTP requests to the load balancer, which will distribute them across the backend servers.
make testYou can view the logs for all services using:
make logsStart the services and test the load balancer:
# Start the load balancer and backend servers
make up
# Test load balancing with parallel requests
make testStop the services when done:
make down