High Availability, Global Load Balancing and Sticky Sessions
Overview
Once a balancer protects your servers, a new question appears: what protects the balancer? This lesson covers making the balancer tier survive failures, sending users to the right region, and why sticky sessions are best avoided.
Detailed Notes
What is a highly available entry layer
It means the front door of your system keeps working even if one balancer, one data centre zone or a whole region fails. Global load balancing is choosing which region should serve a user, before any regional balancer is involved.
The problem it solves
Every request passes through the load balancer, so if it dies, everything behind it is unreachable even if the servers are healthy. Also, users far from your servers feel high latency, and a whole-region outage can take down a product.
How it works
Balancer high availability
- Active-passive: one balancer serves; a standby takes over if it fails. Simple, but the standby sits idle and failover takes seconds.
- Active-active: several balancers all serve traffic. Uses all capacity and has no failover gap, but needs a way to spread traffic across them (DNS returning several addresses, or network routing).
- Managed cloud balancer: the provider runs a fleet across zones for you.
A zone is one isolated data centre location; a region is a group of zones in one geographic area.
Global load balancing techniques:
- DNS-based (geo or latency routing): DNS answers with the nearest or fastest healthy region. Simple, but DNS caching (TTL) delays failover.
- Anycast: many sites advertise the same IP address and internet routing sends each user to the closest one. Failover is fast.
Sticky sessions (session affinity): the balancer sends the same client to the same server, usually via a cookie or IP hash. Why? Some apps keep a user's login or cart in one server's memory, and landing on another server would lose it. The costs: uneven load (a busy user pins one server), sessions lost if that server dies, and harder deploys.
The better fix is stateless servers: keep sessions in a shared store (a database, or signed tokens) so any server can serve any request.
A simple example
A shop chain with branches in several cities: a phone line (global layer) sends you to the nearest open branch, and each branch has several doors (balancers). Stickiness is like insisting on the same cashier because only she knows your order; if she goes home, your order is gone.
System design example
A streaming company had one balancer in one data centre. A power fault took it down and the service was unreachable for two hours, even though servers elsewhere were healthy. Viewers in Asia also saw slow starts because every request went to Europe.
The fix: balancers in two zones per region (active-active), a global DNS layer with health checks that routes users to the nearest healthy region, and sessions in a shared store. After a failover, the remaining regions must absorb all the traffic, so plan capacity for the failure case.
Summary
- Run several balancers across zones; active-active uses capacity best.
- Global load balancing (DNS, anycast) sends users to the nearest healthy region.
- Sticky sessions pin users to servers and cause uneven load and lost sessions.
- Prefer stateless servers with a shared session store.
Architecture Diagram
Global steering plus redundant regional balancers.
- 1Global steering selects the nearest healthy region.
- 2A regional balancer in either zone accepts the request.
- 3A stateless server handles it.
- 4If a zone or region fails, health checks shift traffic to the rest.
Common Interview Questions
Chapter quiz
Load Balancing · 5 questions
1.What is the primary purpose of a load balancer?
2.Which type of load balancer can route based on the URL path?
3.Which algorithm is best when request durations vary widely?
4.Why use connection draining during a deploy?
5.What is the best alternative to sticky sessions?
0 of 5 answered
Finished this lesson?
0 of 91 lessons done · 0% of the course

