Session persistence is a load-balancing technique that associates a client or application session with a selected backend and directs subsequent matching requests there while the association remains valid. Also called sticky sessions or session affinity, it helps applications that keep session data locally on one backend. The load balancer controls the routing association; the application manages the session data.
How It Works
When a request has no usable affinity association, the load balancer selects an available backend according to its routing policy. It establishes an association that later requests can match, using information such as a cookie value or the client's source IP address. Requests with a valid match reuse that association rather than being independently distributed across the backend pool.
A load balancer may set an affinity cookie whose value identifies the chosen backend or refers to a routing mapping. Session persistence does not require that cookie to contain the application's session contents. An application session ID can instead serve as the affinity key, but only if the routing system is configured to use it; the ID alone does not make requests sticky.
When Backend Affinity Helps
Session persistence matters when an application expects related requests to reach a backend holding local session state. If that state exists only in one server's memory, another server cannot access it simply because the request carries the same application session ID. Keeping requests associated with the original backend can let the application continue using that local data.
Shared session storage changes this dependency: any backend able to retrieve the session data can process the request. A stateless application design can also remove the need for backend-local session state. In either case, affinity may no longer be necessary for session continuity.
Looking for liquidity, exploring on-ramp/off-ramp services, or seeking expert guidance?
Get startedSession Data and Cookie Lifetimes
Session persistence is not durable storage for session data. It establishes where requests go, not how long application state survives or how it is recovered. Saving, replicating, and restoring that state require separate application or storage mechanisms.
The term is also separate from the browser distinction between session cookies and persistent cookies. Session cookies are intended to last for a browser session, whereas persistent cookies have a specified expiry. That classification describes cookie lifetime rather than routing behavior. A routing cookie's lifetime and the application's session lifetime need not match. A cookie that remains in the browser does not prove that its routing association is still valid or that the corresponding application session still exists.
Limitations and Operational Considerations
Affinity is conditional, not a guarantee that every request reaches one server for the entire application session. An association may expire, be invalidated by configuration changes, or become unusable when its backend is unavailable. The routing system may then select another backend or handle the request according to its failure policy. If the previous backend held the only copy of session data, routing elsewhere cannot recover it.
Session persistence can also produce uneven backend loads because existing associations constrain request distribution. A backend serving several busy sessions may receive more work than others. Source-IP affinity can compound this imbalance when many clients share one public IP address. Whether affinity is useful therefore depends on where session state lives and how the application handles a lost association.