sticky session pattern
Load balancer pins a client (by cookie, IP, or token) to the same backend instance for the duration of their session. Better for cache hit rate, connection-pool warmup, and any in-memory per-session state. Trade-offs: hot instances get hotter, deploys are messier, and one instance failure drops all of its sessions at once.
Load balancer pins a client (by cookie, IP, or token) to the same backend instance for the duration of their session. Better for cache hit rate, connection-pool warmup, and any in-memory per-session state. Trade-offs: hot instances get hotter, deploys are messier, and one instance failure drops all of its sessions at once.
symptoms
- need in-memory session state but multiple servers
- cache hit rate suffers from random routing
causes
- session state not in a shared store
- caches per-instance and warmup cost is real
fixes
- cookie-based affinity at the LB
- consistent hashing on user id
- better: externalize session state to Redis/DB, drop affinity
you might say
- session affinity
- sticky LB
- pin them to a host