Welcome to the Go Load Balancer project! This load balancer efficiently distributes incoming network traffic across multiple backend servers, ensuring no single server bears too much load. It's perfect for improving the reliability and scalability of your web applications.
A load balancer acts as a traffic cop for your web applications. It:
- Distributes client requests across multiple servers
- Ensures high availability and reliability by sending requests only to online servers
- Provides the flexibility to add or subtract servers as demand dictates
This project implements the Round Robin algorithm for load balancing. Here's how it works:
- Imagine your servers lined up in a circle
- For each new request, the load balancer picks the next server in line
- When it reaches the last server, it starts over from the beginning
It's simple, fair, and effective for many use cases!
- The load balancer receives incoming requests
- It checks the health of all backend servers
- Using the Round Robin algorithm, it selects a healthy server
- The request is forwarded to the chosen server
- The server's response is returned to the client
- β¨ Simple Round Robin load balancing
- π₯ Health checks for backend servers
- π Automatic removal of unhealthy servers
- π¦ Concurrent request handling
- π§ Easy to extend with new balancing strategies
This project uses a Makefile for easy building and running. Here are the main commands:
# Build the project
make build
# Run the load balancer
make run-load-balancer
# Run backend servers
make run-backends
# Run a test
make test
# Stop backend servers
make stop-backends
# Clean up
make clean
- Clone this repository
- Run
make build
to compile the load balancer and backend servers - Start the backend servers with
make run-backends
- In a new terminal, start the load balancer with
make run-load-balancer
- Test it out with
make test
Contributions are welcome! Feel free to submit a Pull Request.
This project is licensed under the MIT License
Happy load balancing! π