A simple, robust HTTP load balancer implementation in Go.
- Round-robin load balancing algorithm
- Automatic health checks for backend servers
- Graceful handling of failed backend servers
- Reverse proxy functionality with custom headers
- Configurable health check intervals
- Go 1.24 or higher
cd go-load-balancer
go run round-robin/load-balancer.go [options]Options:
-port: Port to serve on (default: 8080)-check-interval: Interval for health checking backends (default: 1m)
For testing, you can start multiple instances of the simple backend server:
# Start three backends on different ports
go run backend/simple-backend.go -port 8081
go run backend/simple-backend.go -port 8082
go run backend/simple-backend.go -port 8083- The load balancer distributes incoming HTTP requests to backend servers in a round-robin fashion
- Periodic health checks ensure that requests are only sent to healthy backends
- If a backend fails, it's marked as unavailable until it becomes healthy again
- All requests are proxied transparently with added headers for tracking
round-robin/: Contains the round robin load balancer implementationbackend/: Contains a simple backend server for testing