A load balancer is easy to describe: requests come in, and you send each one to one of several backends. The interesting questions start right after that sentence. Which backend? How do you know one of them is dead? What do you do with a request that was already sent to a dead one? And how do you change the list of backends without dropping the traffic that is flowing right now?
loadbalancer is my learning project for those questions. It is an HTTP reverse-proxy load balancer in Go, using only the standard library and fsnotify. It has three balancing strategies, active health checks, a passive circuit breaker per backend, retries for idempotent requests, config hot reload and Prometheus metrics.
What it does
The request path is short enough to show in full:
request ─► pick(): candidates = healthy ∧ breaker ready ∧ not tried yet strategy.Pick(candidates) → breaker.Acquire() ─► forward(): ReverseProxy to the backend transport error → breaker.Failure(), retry if idempotent 5xx → breaker.Failure(), response…