r/coolgithubprojects • u/weaztoven • 19d ago
loadbear: a small HTTP load balancer in Go (health checks, circuit breaker, rate limiting)
https://github.com/weaztoven/loadbearDisclosure: I'm the author. First time posting here, so sorry in advance if I miss a rule.
loadbear is a small HTTP load balancer / reverse proxy in Go. I built it as a playground to see how concurrency and resilience patterns fit together in one program. It's not meant to replace nginx or HAProxy.
What's in it: round-robin, weighted, least-connections and IP-hash strategies, active health checks, a circuit breaker, retries for idempotent requests only, and per-IP rate limiting. There's also an admin port with /status and a Prometheus-style /metrics.
The most interesting part so far was feedback from a reviewer who asked how the breaker limits half-open probes. A test showed that 100 concurrent requests were all let through. It now admits exactly one. I also found that retries could start after the client's deadline, and that a GET with a non-replayable body could be retried. All of it is fixed in v0.1.1, with regression tests.
I'd love feedback on how failures are handled (breaker, retries, health checks), and on what a small load balancer like this is missing.