Sticky Sessions
Sticky Sessions Routing for Traffic Distributor
On the first visit, a user is routed according to the configured backend weights. After the backend is selected, Traffic Distributor remembers the assignment and sends subsequent requests from the same browser to that environment until the session expires or the routing cookie is removed.
How Sticky Sessions Works
- A new visitor reaches Traffic Distributor.
- The visitor is assigned to one backend according to the configured server weights.
- The selected backend is stored in a session cookie.
- All later requests from the same browser are routed to that backend.
- The assignment ends when the session expires or the cookie is removed.
Cookie-Based Affinity
Some load-balancing systems use the client IP address to maintain affinity. This method can produce uneven results because many users may share one IP address behind a corporate proxy, carrier network, or gateway.
Traffic Distributor uses session cookies instead. Each browser is treated as an individual user, which produces more accurate and balanced assignment.
Backend Weights
New users are distributed in a way similar to Round Robin routing. The configured percentage controls how many new browser sessions are initially assigned to each backend.
Once a user is assigned, later requests stay on that backend regardless of any subsequent traffic-weight change until the existing affinity cookie is no longer valid.
Traffic Distribution Examples
Typical Use Cases
- Applications that store session data locally on the server.
- A/B testing where each user must remain on the same application version.
- Gradual rollout of a new release to a controlled percentage of users.
- Applications where switching a user between backends could interrupt an active workflow.
- Testing a new backend with a small share of new visitors before increasing traffic.
Important Considerations
- Sticky Sessions maintains affinity but does not synchronise application files, databases, or server configuration.
- The two backends may run different application versions for A/B testing, but each version must remain compatible with shared services and data.
- Deleting cookies or allowing the session to expire causes the user to be treated as a new visitor.
- If an assigned backend becomes unavailable, routing behaviour depends on the configured health checks and Traffic Distributor settings.
- For fully stateless applications with shared session storage, Round Robin may provide simpler and more even request distribution.
