Sticky sessions ensure that requests from a client always get routed to the same backend server before a session elapses.
Here is an example that describes what sticky sessions. Assume that you have logged in to a server. After a while, you send another request. If sticky sessions are not enabled, the request may be routed to another server, and you will be asked to log in again. If sticky sessions are enabled, all your requests are processed by the same server, and you do not need to repeatedly log in.
Sticky sessions at Layer 4 are different from those at Layer 7.
You have selected Weighted round robin for Load Balancing Algorithm.
OSI Layer |
Listener's Protocol |
Sticky Session Type |
Stickiness Duration |
Scenarios Where Sticky Sessions Become Invalid |
---|---|---|---|---|
Layer 4 |
TCP or UDP |
Source IP address: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all backend servers are numbered. The system allocates the client to a particular server based on the generated key. This enables requests from different clients to be routed and ensures that a client is directed to the same server that it was using previously. |
|
|
Layer 7 |
HTTP or HTTPS |
|
|
|
Dedicated load balancers support two types of sticky sessions: Source IP address and Load balancer cookie
Shared load balancers support three types of sticky session, including Source IP address, Load balancer cookie, and Application cookie.
Classic load balancers support Source IP address.
Classic load balancers can no longer be created on the management console. Use shared load balancers or dedicated load balancers instead.
For a classic load balancer, click Listeners, locate the listener, and click Modify in the Operation column.
You can also configure sticky sessions when adding a listener or creating a backend server group.
Parent topic: Listener