We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Load Balancing Proxies
Free preview: the first part of this 11-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Load Balancing Proxies
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
The previous lesson ended on one sentence: stickiness is a routing answer to a storage question.
That is worth unpacking, because it is the most useful thing in either lesson. Every cost of sticky sessions came from the same place. The fleet went uneven because users were pinned. Adding servers did not help because existing users stayed pinned. A routine deploy logged people out because the machine holding their session went away. None of that is a property of load balancing. All of it is a property of the session living inside one process's memory.
So this lesson asks the storage question directly. Where does the session go?
There are only three answers, and every real system is one of them or a deliberate mix of two.

Read the middle column first. Each row costs something on every single request, and the costs are completely different in kind: a lost machine, a network hop, or the ability to take a session back.
The first row is what you get by default. Nearly every web framework, out of the box, keeps the session in the memory of the process that created it. Nobody chooses that. It is simply what happens when nobody chooses anything, and stickiness is the routing configuration people reach for once it starts hurting.
The other two rows are choices. Making one of them makes the entire affinity question disappear instead of managing it forever.
Here is what that looks like when you actually run it.

Four requests with one cookie landed on three different machines and every machine knew who the user was. Then a backend was removed mid-run and nothing changed. Compare that with the previous lesson's capture, where removing the pinned backend lost the session immediately.
This is deliberately the same three backends, the same proxy, the same cookie and the same client as the sticky-sessions capture. Exactly one thing is different: the backends read and write the session through a store all three can see, instead of keeping it in their own memory. Stickiness is off. The is doing nothing clever whatsoever.
That is the whole idea of this lesson in one screen. The routing did not get smarter. The state stopped being somewhere only one machine could see.