iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

2.4 LB & Failover

System availability is uptime as a percentage. Load balancing distributes traffic; failover shifts it on failure. The arithmetic from nines to minutes is the worked example in this section.

2.4 System Availability: Load Balancing and Failover

Availability in nines

NinesUptime %Annual downtime
Two99.0~3.65 days
Three99.9~8.77 hours
Four99.99~52.6 minutes
Five99.999~5.26 minutes
Six99.9999~31.5 seconds

365 days x 24 hours x 60 minutes = 525,600 minutes per year. Every extra nine costs roughly 10x in redundancy.

Load balancing - types and choices

TypeRouting keyUse
L4 (TCP)IP + portCheap, fast, opaque
L7 (HTTP)URL, cookie, headerApplication-aware
DNS-basedWeighted recordsCoarse-grained
AnycastSame IP everywhereCDNs, global services

Algorithms: round-robin, least-connections, weighted, hash-based.

Failover - cold, warm, hot

ModeSpare stateCutover time
ColdHardware offHours; cheapest
WarmBooted, idleMinutes
HotRunning + receivingSub-second; costly

Active-active vs active-passive

Active-active Active-passive Load Balancer App A App B Both serve; sessions sticky or stateless Load Balancer App A (active) App B (standby) Standby waits; promotes on failure Figure 2.4 - Active-active doubles capacity; active-passive is simpler to operate.

Worked example - bank online banking

ItemValue
SLA target99.95 % availability
Budget~263 minutes (4 hr 23 min) of downtime per year
ArchitectureL7 LB + active-active app tier + DB primary/standby
FailoverSub-second for app, ~30 sec for DB promotion

Common pitfalls

  • DNS TTL stuck at hours; failover takes hours to propagate.
  • 'Active-active' database without conflict resolution; data loss on
  split-brain.
  • Health checks too lenient; failing nodes keep getting traffic.
Mentor’s tip: Nines convert to minutes via 525,600. Every extra nine multiplies redundancy cost by ~10. L4 vs L7 vs DNS vs anycast - pick by what you actually need to route on. Failover speed is bounded by your state model, not your hardware.

Test yourself

Q1. 99.99% uptime translates to roughly:
Q2. Active-active failover means:
Q3. A Layer-7 load balancer routes based on:
Q4. RPO is defined as:
Q5. To achieve five-nines you typically need:

Discussion

Loading…