Sticky session
Definition
A sticky session (session affinity) binds a client to one backend instance, so state kept in that instance's memory is available on every later request.
In practice
Affinity lets legacy applications keep sessions or caches in local memory without a shared store, and it can raise cache hit rates. Balancers implement it with a cookie they set themselves, an application cookie or a hash of the source IP. For WebSockets it matters only for where reconnects land: an open connection is already pinned to its server.
It undermines statelessness: load becomes uneven because heavy users stay put, a failed instance loses its users' sessions, and new instances get traffic only from new clients, which slows scale-out. IP hashing breaks behind NAT and mobile networks. Prefer moving state to a shared store and use affinity as an optimisation, not as a correctness requirement.
Example
The balancer sets an AWSALB cookie so a shopper's cart, held in one instance's memory, survives page loads; when that instance is replaced, 4,000 shoppers lose their carts.