CodePark/ questions / Load balancing & proxies
START PRACTICINGPRACTICE
Backend question · System design & architecture › Load balancing & proxies

What is the main downside of sticky sessions (session affinity) on a load balancer?

Load can become uneven, and when an instance dies its users lose their in-memory sessions

Sticky sessions (affinity) pin each client to one instance. This causes three problems:
• A few heavy users can overload their instance.

• New instances take a while to receive traffic.

• When an instance crashes or is removed during scale-in, the sessions stored on it are lost.


Sticky sessions are a workaround for
stateful servers, which keep session data in memory. If you move session state to a shared store, such as Redis, you no longer need them.

They have nothing to do with "They only work over HTTP/2" or "They prevent TLS termination at the load balancer". In fact, cookie-based stickiness needs the load balancer to terminate TLS so it can read the cookie.