/system-design-skills:load-balancingfrom system-design-skills
Guides on designing and configuring load balancers: L4 vs L7, balancing algorithms, health checks, sticky sessions, TLS termination, and avoiding common pitfalls like SPOF or YAGNI.
Ships in system-design-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Spread incoming requests across a pool of identical backends so no single server is the bottleneck or the single point of failure. Get it wrong and the balancer becomes the SPOF it was meant to remove, routes traffic to dead servers, or amplifies an outage by hammering a backend that is already on its knees.
Reach for a balancer when more than one backend serves the same role and traffic must be split across them; when a single entry point is a SPOF to eliminate; to add or remove servers without clients noticing (the enabler for the stateless tier and autoscaling); or to put one public address in front of a private fleet, with TLS termination, health-gating, and routing in one place.
One backend that comfortably handles peak load needs no balancer yet — adding one
is a new component, a new failure mode, and a new thing to operate (YAGNI). If the
real bottleneck is the database or a single hot shard, a balancer in front of the
web tier solves nothing; diagnose the actual constraint first (→ back-of-the-envelope).
Cross-region traffic steering is usually DNS/anycast at the edge, not an L4/L7
balancer (→ content-delivery). Per-client request limiting is a policy concern
owned by resilience-failure, not the balancing algorithm.
back-of-the-envelope)./healthz 200? a
deep dependency check?) and how fast must a dead node leave the pool?Layer of inspection
Distribution algorithm
Topology
Reverse proxy role: an L7 balancer is also a reverse proxy — one public face that hides backends, terminates TLS, compresses, caches, and centralizes routing. A reverse proxy is worth it even with a single backend for those benefits; load balancing is the multi-backend case of the same component.
| Option | What it solves | What it worsens | Change it when |
|---|---|---|---|
| L4 balancing | Max throughput, low latency, any protocol | Blind to content; no path/header routing, no TLS inspection | You need content-based routing or TLS termination → L7 |
| L7 balancing | Content routing, TLS offload, rewrites, observability | Higher latency/CPU; terminates connections (more state) | Raw throughput dominates and routing is trivial → L4 |
| Round robin | Dead simple, even for uniform work | Ignores actual load; a slow node still gets its share | Request costs vary a lot → least-connections |
| Least connections | Adapts to uneven request cost | Needs live connection state; can herd onto a just-recovered node | Backends are uniform → round robin is enough |
| IP/consistent hash | Affinity & cache locality without session store | Uneven spread; rebalances on pool change | You can externalize state → round robin + shared store |
| Sticky sessions | Works with stateful backends today | Breaks even spread, complicates scale-in, loses session on node death | State can move to Redis/DB → drop affinity |
| Active-passive | Simple HA for the balancer | Idle standby; failover gap (seconds) | You need zero-gap headroom → active-active |
The balancer sits in the request path of everything, so its failure modes are the whole system's failure modes.
resilience-failure).resilience-failure).Monitor: per-backend request rate and latency (p99), healthy-host count, health-check pass/fail and flap rate, connection counts, 5xx rate at the balancer vs. at backends (divergence localizes the fault), and active connection distribution.
back-of-the-envelope.Decision | Solves | Worsens | Change it when… table with one row per choice you made here (e.g. the
option, its store, its failure policy); the last column is a concrete trigger
(a number or observable signal). Then name what breaks first.Do
Don't
A modern software balancer (HAProxy/Nginx/Envoy) handles tens of thousands of
requests/sec and many thousands of concurrent connections per instance — usually
well above a single web/app node, so it is rarely the first bottleneck. Size it
against peak QPS and concurrent connections, and confirm the backend fleet (not
the balancer) is the binding constraint. Per-server QPS rates, connection-memory
cost, and peak-factor math live in back-of-the-envelope — don't restate them
here; pull the figures from there to size the pool and the balancer.
Load balancing has no request/response contract of its own, but two configs are load-bearing and worth writing down concretely:
GET /healthz → 200, every 5s, unhealthy after 3 fails, healthy after 2 passes.
Make /healthz shallow (process alive) vs. deep (checks DB) deliberately — a
deep check that fails on a slow dependency can evict the whole fleet at once.host:port targets, weights, and
the drain/deregistration delay used on scale-in so in-flight requests finish.Spreading requests freely across interchangeable servers only works if any server
can serve any request — i.e. no session state lives on the box. Push session/state
into a shared store (Redis/DB) so the balancer can use plain round robin, add or
remove nodes at will, and let an autoscaling group grow/shrink the pool. Sticky
sessions are the fallback when state can't move yet, at the cost of even spread
and easy scale-in. The horizontal-scale and stateless-tier story is owned by
scaling-evolution; this skill is the mechanism that makes it routable.
Default to the generic recipe above. If the user names a cloud, read
references/providers/<provider>.md for the managed-service mapping,
quotas/limits, and provider-specific trade-offs. If no file exists for that
provider, the generic recipe is the answer.
To visualize the request path (client → balancer → backend pool) or the
health-check/failover flow, use the in-plugin architecture-diagram skill. A
quick inline sketch — client → [LB] → {web1, web2, web3} → shared state — is
fine for reasoning; do not embed Mermaid.
scaling-evolution — feeds into this: it owns the stateless tier and
horizontal vs. vertical scaling, and this skill is the routing mechanism that
makes that fleet addressable.resilience-failure — pairs with this whenever the balancer can amplify an
outage; owned-concept lives in it — retries/backoff/jitter, circuit breakers,
failover, and rate limiting are the cure for health-check stampedes and retry storms.content-delivery — alternative to this for cross-region traffic: when
"balancing" is really steering users to the nearest region, geo/DNS/anycast at
the edge (owned there) is the right tool, not an L4/L7 balancer.back-of-the-envelope — depends on it for the QPS, connection, and
peak-factor numbers that size the pool and the balancer.system-design — the orchestrator that routes here when a design grows past one
server.references/deep-dive.md — L4 NAT vs. DSR, how L7 termination works, the
algorithm internals (incl. consistent hashing for affinity), health-check tuning
and slow-start, connection draining, TLS termination vs. passthrough. Read when
configuring a balancer in detail.references/providers/{generic,aws,azure,gcp}.md — service mappings, limits,
and pitfalls per environment.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub proyecto26/system-design-skills --plugin system-design-skills22 skills in this plugin
/api-designThis skill should be used when the user needs to "design the API", do "endpoint design", pin down a "request/response shape", choose a "pagination" strategy (cursor vs offset), add an "idempotency key" to a write, plan "API versioning", an "error contract", or pick between "REST vs gRPC vs GraphQL" or "WebSocket vs polling". Use it whenever a design has reached the interface — the concrete request, response, primary access path, and how clients page, retry, and version — even if the user only said "the boxes talk to each other"./architecture-diagramThis skill should be used when a system design needs a diagram — "draw the architecture", "diagram this system", "show the components", "make an architecture/infrastructure/topology diagram", or visualizing boxes-and-arrows, data flow, regions, or failure paths for a design. It generates a self-contained dark-theme HTML + SVG diagram (with PNG/PDF export). Use it whenever the `system-design` orchestrator or a building block reaches the "draw it" step, even if the user doesn't say "diagram"./back-of-the-envelopeThis skill should be used when the user needs to "estimate QPS", "back-of-the-envelope" (BOTEC) numbers, "how much storage / bandwidth", "how many servers", "peak load", "capacity planning", or wants the standard latency / throughput / availability numbers to ground a design (latency table, QPS rates, powers of two, nines). Use it whenever a design decision hinges on scale — convert any "high traffic" / "huge data" phrase into concrete numbers before choosing components, even if the user doesn't say "estimate". Prefer it even for a quick "rough numbers" question (DAU × actions/day → QPS, storage per day/year, replication): it carries a calculator and the reference numbers, so the arithmetic and unit conversions are checked instead of done from memory./blob-storeThis skill should be used when the user wants a "blob store" or "object storage", names "S3" or an S3-compatible store, needs to "store images / video / files", asks about "multipart upload" or "resumable upload", "signed / presigned URLs", "media storage", "unstructured data at scale", object "versioning", storage "tiering" (hot/cold/archive), or "erasure coding" vs replication for durability. Use it whenever a design must hold large unstructured objects (photos, video, backups, logs, ML datasets) and serve them cheaply and durably, even if the user just says "where do we put the files"./cachingThis skill should be used when the user asks about a "caching strategy", "cache invalidation", "what to cache", "read-through vs write-through vs write-back", "cache eviction" (LRU/LFU/TTL), "Redis vs Memcached", "stale reads", or hits "thundering herd", "cache stampede", "cache penetration", or "hot key" problems, or is choosing a Redis `maxmemory` eviction policy (allkeys-lru, volatile-lru, noeviction) vs TTL expiry for sessions or other cached state. Use it whenever a design is read-heavy or a datastore is overloaded by reads, even if the user doesn't say "cache"./consistency-coordinationThis skill should be used when the user asks about the "CAP theorem", "PACELC", a "consistency model", "eventual vs strong consistency", "read-your-writes", "causal consistency", "quorum" or "R+W>N", "consensus", "Raft / Paxos", "leader election", "consistent hashing", a "distributed transaction", "2PC", or "saga". Use it whenever a design has multiple copies of data or coordinating nodes and a decision hinges on what a reader is guaranteed to see during replication lag, a network partition, or a node failure — even if the user doesn't say "consistency".Other plugins' skills for the same job