The Desi Architect
Notes / Docker Sandboxes / gRPC Load Balancing: L4 Connection Pinning vs L7 Stream Multiplexing
Docker Sandboxes · Tier 3: Reliability & Messaging · Lab 69

gRPC Load Balancing: L4 Connection Pinning vs L7 Stream Multiplexing

Why does standard Layer 4 TCP load balancing send 100 percent of your gRPC traffic to a single container? See HTTP/2 connection reuse pin all RPC calls to one backend instance, watch one replica burn at 100 percent CPU while the other sits idle, and switch to an L7 reverse proxy that unpacks HTTP/2 binary frames to distribute individual streams evenly.

Time25 minutes
StackgRPCPorts 18360, 18361
MemoryAbout 120 MB
Before thisLab 01Docker Compose Basics
Verified runWindows, Mac, LinuxBash and PowerShell
  1. 1PrepareWhat you will learn
  2. 2PredictGuess before you run
  3. 3RunStep by step
  4. 4ObserveWhat you should see
  5. 5Break itChange one thing
  6. 6Clean upLeave nothing running
On this page
  1. 00 / What You Will Learn
  2. 01 / Why It Matters
  3. 02 / What We Are Building
  4. 03 / Words You Need
  5. 04 / Predict First
  6. 05 / Step by Step
  7. 06 / What You Should See
  8. 07 / Look Inside
  9. 08 / Break It, Fix It
  10. 09 / In Real Projects
  11. 10 / Interview Corner
  12. 11 / Clean Up

00 /What You Will Learn

By the end you will be able to
  • Explain how HTTP/2 multiplexing merges hundreds of logical RPC calls onto a single persistent TCP socket.
  • Demonstrate why Layer 4 (TCP) proxies only balance connections during the initial handshake and never rebalance subsequent RPCs.
  • Reproduce connection pinning where 100 percent of requests land on a single backend instance.
  • Configure Layer 7 reverse proxies (Nginx grpc_pass or Envoy) to inspect binary frames and balance streams round-robin.
  • Identify production mitigation strategies including client-side load balancing and MAX_CONNECTION_AGE draining.

Before you start

Complete Lab 01 (Docker Compose Basics) and Lab 11 (Nginx Load Balancer) first. You should understand basic reverse proxy upstreams and round-robin routing. Docker Desktop must be running.