Intelligent Kubernetes Load Balancing
Intelligent Kubernetes Traffic Routing: How We Reduced Latency Without Scaling More Pods
Most Kubernetes clusters distribute traffic blindly. Here’s how intelligent routing improves latency, resilience, and scalability.
Imagine standing in front of a busy supermarket checkout line.
There are ten cashiers.
Nine of them are completely free, twiddling their thumbs.
But one checkout lane is pure chaos.
A customer is arguing about an expired coupon.
A 24-pack of soda just exploded across the floor.
The cashier is overwhelmed.
The line is growing longer every second.
Now imagine the store manager watching all of this…
…and still forcing the next customer into that exact broken line.
Not because it’s efficient.
Not because it’s fast.
But because a random number generator said so.
You’d assume the manager had completely lost it.
But here’s the uncomfortable part:
If you’re running a default Kubernetes cluster in production today, this is exactly how your networking behaves.
Hundreds of times per second.
Under the hood, Kubernetes typically relies on kube-proxy running in iptables mode.
And its traffic distribution strategy is shockingly primitive:
Random selection.
It doesn’t know whether a pod is:
- frozen in a 500ms Java GC pause
- choking at 99% CPU
- seconds away from failure
- drowning under queue pressure
It just rolls the dice…
…and forwards traffic blindly.
When every pod is healthy and identical, this works well enough.
But production systems are never clean.
They’re noisy.
Uneven.
Chaotic.
And randomness under chaos becomes latency.
Then retries.
Then cascading failures.
Then brutal P99 spikes that wake engineers up at 2 AM.
Modern platform teams are finally moving beyond this default behavior.
Here’s how intelligent traffic routing is replacing “spray and pray” networking inside Kubernetes.
The Blind Spots of Default Routing
Let’s look at what actually happens when Service A talks to Service B.
By default, kube-proxy writes a massive set of iptables rules onto every Kubernetes node.
When traffic hits a Service IP, the Linux kernel starts walking through those rules one by one.
Then comes the critical part:
The kernel’s statistic module effectively flips a weighted coin.
Based on randomized probability, it selects a destination pod and forwards the packet.
Get Ramesh | The Platform Engineer’s stories in your inbox
Join Medium for free to get updates from this writer.
That’s it.
There are three massive blind spots to this approach:
- No Latency Awareness: It routes traffic to a pod even if that pod’s active connection queue is full.
- No Topology Awareness by default unless topology hints are enabled: It happily sends traffic across availability zones, incurring cloud egress charges and adding milliseconds of latency, even if there is a healthy pod on the exact same node.
- Sequential Rule Bottlenecks: As services scale,
iptablesrules must be updated per node and can become slow at scale. (Note: Kubernetes 1.31+ is moving thekube-proxybackend tonftablesspecifically to solve this performance bottleneck, but the fundamental logic of blind packet routing remains the same.)
You can verify on your cluster:
kubectl -n kube-system get configmap kube-proxy-config -o yaml | grep modenftables fundamentally fixes the scaling and update inefficiencies of iptables, but does not change the core limitation: routing decisions are still blind to application health.
Even if you configure kube-proxy to use IPVS mode to get true round-robin behavior, you are still bound by Layer 4 blindness.
Before we continue
If you found this story insightful, …
👏 Clap 50 times (yes, you can, simply hold the button), it will help me a lot. Medium’s algorithm favors this, increasing visibility to others who then discover the article.
🔔 Follow me on Medium and subscribe to get my latest articles straight to your inbox.
Level 1: Topology Aware Traffic Distribution
The easiest, zero-infrastructure win for most clusters is turning on Kubernetes native topology-aware routing.
Historically, this required complex annotations (service.kubernetes.io/topology-mode), but modern Kubernetes versions (1.30+) have vastly simplified this by introducing a native trafficDistribution field directly into the Service spec.
apiVersion: v1
kind: Service
metadata:
name: payment-service
spec:
# Instructs kube-proxy to prefer endpoints in the same AZ
trafficDistribution: PreferSameZone
selector:
app: payment
ports:
- protocol: TCP
port: 80
targetPort: 8080When enabled, the Kubernetes control plane injects routing hints.
If Service A in us-east-1a needs to talk to Service B, it will keep traffic local within us-east-1a whenever endpoint capacity allows.
If the local zone is under-provisioned, it seamlessly spills over.
The result?
Immediate reduction in cross-AZ cloud provider egress costs and lower baseline latency.
Level 2: The eBPF Revolution with Cilium
If you want true high-performance, intelligent L4 balancing, you may choose to replace kube-proxy entirely.
Then the industry realized something radical:
Maybe kube-proxy itself was the bottleneck.
Enter eBPF and Cilium.
Instead of dealing with iptables or nftables, Cilium loads eBPF programs directly into the Linux kernel. When a packet arrives, eBPF instantly maps the Service IP to a backend pod IP using an hash table lookup.
But Cilium goes beyond speed. It enables Maglev Consistent Hashing.
With Maglev consistent hashing, the same 5-tuple (source/dest IP, source/dest port, protocol) always routes to the same backend pod.
This is crucial for stateful or caching layers. If your frontend talks to a Redis cache pool, consistent hashing significantly improves cache locality and hit rates, whereas generic random selection would destroy your cache performance by spraying requests everywhere.
Level 3: Peak Intelligence with L7 Proxies
eBPF is brilliant for Layer 4, but the network usually doesn’t know anything about the actual HTTP/gRPC request.
To solve the P99 latency problem permanently, you need Layer 7 intelligence.
This is where an Envoy-based proxy (via Istio, Linkerd, or the Gateway API) takes over.
Instead of blind routing, an L7 proxy uses Least Request Load Balancing or Exponential-Weighted Moving Average (EWMA) Latency LB.
The proxy actively monitors every backend pod’s response queue.
If Pod 12 is experiencing a CPU spike and its active connection queue stalls, the proxy mathematically deprioritizes it.
The bulk of new traffic seamlessly shifts to Pod 43, which is idle.
Furthermore, Outlier Detection can temporarily eject Pod 12 entirely if it starts returning 5xx errors.
# Applying L7 intelligent load balancing via Istio
apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
name: payment-dr
spec:
host: payment-service
trafficPolicy:
loadBalancer:
simple: LEAST_REQUEST
outlierDetection:
consecutive5xxErrors: 3
interval: 10s
baseEjectionTime: 30sWith LEAST_REQUEST, the proxy essentially says: “Give me the two pods with the fewest active connections, and I’ll send the request to the better of the two.” (Known as the Power of Two Choices).
It mathematically prevents the “thundering herd” problem and virtually eliminates artificial latency spikes.
The Verdict
Relying on default kube-proxy networking in a high-traffic Kubernetes cluster is like playing Russian roulette with your user experience.
If cost and quick wins are your primary concern, adopt trafficDistribution: PreferClose today. If network latency and sheer throughput are your bottlenecks, adopt an eBPF CNI like Cilium. And if you are battling unpredictable P99 latency spikes in heavily-loaded microservices, it's time to route intelligently at Layer 7.
Stop treating all your pods equally. Evolve your routing.







