A simple HTTP load balancer implemented in Go with round-robin distribution and automatic health checking.
- Round-robin load balancing across multiple backend servers
- Automatic health checks (every 10 seconds)
- Instant failure detection and retry on next available backend
- Graceful handling when backends go down/come back up
go run main.goThe load balancer starts on port 8080 and distributes traffic to backends defined in main.go.
Start test backend servers:
cd testserver && go run main.go 8081
cd testserver && go run main.go 8082
cd testserver && go run main.go 8083Send requests:
curl http://localhost:8080- Receives incoming requests on port 8080
- Selects next healthy backend using round-robin algorithm
- Proxies request to selected backend
- If backend fails, immediately tries next available backend
- Health checks run every 10 seconds to detect recovered backends