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.
Features
- 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.yml
file.
- Command-line interface (CLI) for building, running, and testing using
make
.
- Supports automated testing of load balancer performance with
curl
.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
- 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
make
is installed to run the commands from the provided Makefile.
Installing
Clone the repository to your local machine:
git clone https://github.com/nullsploit01/cc-load-balancer
cd cc-load-balancer
Building
You can build the project using the Makefile, which handles Docker image building for both the backend servers and the load balancer.
make build
Running
Once the images are built, you can start the load balancer and backend servers using:
make up
To stop the services, use:
make down
Testing
You can test the load balancer by making parallel HTTP requests to the load balancer, which will distribute them across the backend servers.
make test
Logs
You can view the logs for all services using:
make logs
Example Usage
Start the services and test the load balancer:
# Start the load balancer and backend servers
make up
# Test load balancing with parallel requests
make test
Stop the services when done:
make down