Repo: https://github.com/roy2220/clbtransport
Kubernetes is the usual infra for cloud-native workloads at present, and most backend builders finally hit the identical wall: calling one other service by means of its Kubernetes Service DNS identify over plain HTTP results in uneven load throughout backend pods.
The standard fixes folks attain for are:
- The Kubernetes Endpoints API
- A gateway / load balancer
- A service mesh
However does it actually should be this heavy?
Take into consideration the best case: if each single request picked a goal node at random from the entire pool proper earlier than sending, the cluster load would find yourself balanced (assuming all nodes are roughly equal in capability).
Brief-lived HTTP connections mixed with disabled DNS caching get you precisely that — however at a value no person needs to pay: each request now pays for a DNS lookup, a TCP handshake, and a TCP teardown.
So long-lived (keep-alive) connections are non-negotiable. The actual drawback turns into controlling how usually a request will get to re-pick its goal node:
- Too uncommon, and site visitors piles up on whichever node was picked first.
- Too frequent, and the price of continually re-establishing TCP connections eats the balancing profit.
clbtransport controls that frequency alongside two axes:
- Sure connection lifetime. Lengthy-lived connections aren’t allowed to stay perpetually — after a while (with jitter, to keep away from synchronized reconnects) they’re retired, giving requests a contemporary probability to land on a distinct node.
- Unfold connections per host. Since connection lifetime can’t be pushed arbitrarily low with out hurting latency/SLA (TCP setup blocks the request), a small variety of impartial connections are stored “sizzling” per host in parallel, multiplying the alternatives for requests to fan out throughout nodes.
The outcome behaves like a regular http.RoundTripper — a drop-in substitute for http.Transport — that quietly rebalances site visitors within the background as a substitute of counting on cluster-side equipment.

