This project includes a simple load balancer (lb
) and 3 backend servers (backend
) written in Go, which are containerized using Docker. The load balancer forwards incoming HTTP requests to the backend server, which responds with a simple greeting.
To be fair, I just did this because I wanted to make a load balancer and I think its fun to build things like this...
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Go 1.18 or higher
- Docker
- Docker Compose
Clone the repository to your local machine:
git clone https://github.com/yourusername/own-load-balancer.git
Navigate to the root directory of the project and run the following command to build and start the services using Docker Compose:
docker-compose up --build
This command will start 4 Docker containers:
backend services: The backend servers listening on port 8080, 8081 and 8082. lb: The load balancer listening on port 80 and forwarding requests to the backend server.
After the services are running, you can send a request to the load balancer using curl:
curl http://localhost/
you also can test it making concurrent requests with:
curl --parallel --parallel-immediate --parallel-max 3 --config urls.txt