This project implements a custom software-based load balancer in Go, complete with a real-time dashboard visualization. It dynamically distributes incoming HTTP requests across multiple backend servers using the Least Connections algorithm.
- Backend Servers: Simple Go HTTP servers that handle incoming requests and respond after a configurable delay.
- Custom Load Balancer: A Go-based load balancer that forwards incoming HTTP requests to backend servers.
- Health Checks: Periodically checks if backend servers are healthy and dynamically removes unhealthy servers from rotation.
- Visualization Dashboard: A real-time dashboard built with HTML, JavaScript, and Chart.js to visualize server load and health status.
- AWS Infrastructure: Deployment of backend servers and load balancer onto AWS EC2 instances.
- Nginx Reverse Proxy: Nginx server set up as a reverse proxy in front of the Go load balancer to provide standard HTTP port access, SSL termination, and efficient static content serving.
- Load Testing: Using tools like ApacheBench (
ab) or Siege to simulate real-world traffic and verify correct load distribution.
| Technology | Purpose |
|---|---|
| Go | Backend & Load Balancer logic |
| Nginx | Reverse proxy & static content serving |
| AWS EC2 | Cloud hosting infrastructure |
| Systemd | Service management |
| Apache Bench (ab), curl | Load testing |
| Chart.js | Real-time visualization |
| HTML/CSS/JavaScript | Dashboard frontend |
- Write simple HTTP servers in Go.
- Implement
/healthendpoint for health checks. - Include artificial delays for testing purposes.
- Implemented in Go, using the Least Connections algorithm.
- Regularly performs health checks on backend servers.
- Provides API endpoints for real-time statistics visualization.
- HTML dashboard using Chart.js to visualize active connections per server.
- Fetches real-time data from
/api/server-statsendpoint provided by the load balancer.
- Deploy backend servers and load balancer on separate EC2 instances.
- Configure security groups to allow necessary traffic (HTTP ports).
- Installed on the load balancer instance.
- Forwards HTTP requests from port 80 to the Go application running on port 8080.
- Use Apache Bench (
ab) or Siege to simulate high traffic scenarios. - Monitor real-time server loads through the visualization dashboard.
The implemented algorithm is called "Least Connections," a dynamic load balancing method that distributes incoming requests based on the current number of active connections each backend server has:
- When a new request arrives, the load balancer checks all available and healthy backend servers.
- It selects the server currently handling the fewest active connections.
- The request is forwarded to this selected server, incrementing its active connection count.
- Once the request completes (and after an optional delay), the active connection count is decremented.