Session Persistence Definition
Session Persistence (sometimes called sticky sessions) involves directing a user’s requests to one application or backend web server for the duration of a “session.” The session is the time it takes a user to complete a transaction or task that might include multiple requests.
As users browse high-traffic websites, they each request information from various backend servers, often using standard http protocols. This means the server is supporting many users at once, and performance can be a problem.
A load balancer can sit in front of the site’s server group to manage where user requests go. However, standard load balancing algorithms can direct user requests to unique backend or application servers each time.
Some load balancers can instead achieve session persistence. By directing requests to the same server—for example, where information is already cached or where information likely to be requested based on existing patterns is already being stored—the load balancer ensures the most efficient possible performance.
What is Session Persistence?
Session persistence ensures that a client will remain connected to the same server throughout a session or period of time. Because load balancing may, by default, send users to unique servers each time they connect, this can mean that complicated or repeated requests are slowed down.
Session persistence ensures that, at least for the duration of the session or amount of time, the client will reconnect with the same server. This is especially important when servers maintain session information locally.
How Does Session Persistence Work?
Load balancer session persistence boosts performance by configuring a backend server to work efficiently with user requests. This kind of load balancer sits between users and the website’s server group and implements logic that connects specific servers to user sessions for as long as is needed.
For example, the backend server is likely to save steps as it fulfills larger requests by caching data about user requests. It will also anticipate which additional data a user might need and cache that as well to shave time off future requests.
This is important because servers break down many client requests that seem simple—such as downloading large files—into multiple request-response transactions. If a single server has already anticipated some requests and cached data in response to them, it will perform more quickly and efficiently.
In other cases, session persistence provides session context. For example, a user might need to buy something, upgrade an account, or fill out a form. Perhaps they initially place something in an online shopping cart, establishing a session. These kinds of transactions demand that users take multiple steps, and as the user exchanges data with the server, it has to store some of that data to proceed. All subsequent requests will go to the same server to save time and resources.
Session persistence enables all of these kinds of exchanges between client and server to happen more smoothly and quickly.
What is a Sticky Session?
Load balancer persistence sticky sessions can help optimize network resource usage and improve user experience.
Session persistence, also called session stickiness, results in a “sticky session” between a user and a particular server. In this process, a load balancer uses logic to find an affinity between a specific network server and a client for the length of an entire session, defined by the amount of time a unique IP address stays on the site.
A load balancer creates sticky sessions by either tracking a user’s IP details or using a cookie to assign that user an identifying attribute. This allows the load balancer to use the tracking ID to route all of that user’s requests to a specific server throughout the session.
Compare Session Cookies vs Persistent Cookies
The persistent cookie vs session cookie comparison actually returns to the difference between browser-length sessions and persistent sessions. The system creates a session cookie as a kind of session ID and stores it in the instance of the browser from that session. Once the user ends that session and closes the browser and the data associated with it, any associated session cookies are deleted. (Or at least this happens soon after the session times out.)
The computer itself stores a persistent cookie, meaning it lasts even between instances of closing and opening the browser. This is why you can reopen your browser and it will still remember your login credentials for your favorite sites, for example. The “stay logged in” option is typically stored in a persistent cookie on the user’s machine, enabling the server to check you as a user for authenticity via an algorithm the next time you are there.
How can Avi Networks Help?
If you’re wondering how to configure session persistence for web applications, Avi Networks presents a simple but powerful load balancing solution that enables session persistence. Use Avi to create persistence profiles for clients, including: