The sticky session function enables the FW to allocate the traffic from one client to the same real server within a specific period of time.
The sticky session function applies to two scenarios. 1. A client needs to interact with a server for multiple times to fulfill a task. 2. A server stores service information about a client, so it is better to let the server process all requests from the client. In either scenario, the service traffic from one client must be distributed to the same server. If the server is changed during interaction, the client cannot complete the operation and has to re-initiate a request.
If no ID is specified to create a new sticky session profile, the system automatically assigns an idle ID to the sticky session profile.
The created sticky session profile can be referenced during virtual service configuration.
By default, the sticky session mode is the source IP address-based sticky session mode.
If the virtual server protocol is SSL, the sticky session mode can be session-id or source-ip. If the virtual server protocol is HTTP or HTTPS (SSL uninstallation is configured for HTTPS), the sticky session mode can be cookie-insert, cookie-passive, cookie-rewrite, or source-ip. If the virtual server protocol is another protocol, the sticky session mode can only be source-ip. If the sticky session mode is not selected correctly, a prompt "virtual server protocol conflicts with the session persistence mode" is displayed.
If many clients access the server through the proxy or source NAT, the sticky session mode source-ip is not preferred. If the sticky session mode source-ip is set, the connections of all clients are allocated to one real server, causing server load unbalancing.
When the sticky session mode is cookie-insert, cookie-passive, or cookie-rewrite, you can run the cookie-name command to set the name of the cookie carrying sticky session information. For example, the default format for the sticky session information of an SLB module inserted into the cookie is SLBServerpool=example.xxxx. By using the cookie-name cookie-value command, the insertion information can be set to cookie-value=example.xxxx. The names of cookies in different sticky session algorithms must be different. If the sticky session mode is Source-IP or SSL Session ID, this function is not supported.
# Set the sticky session mode to Cookie-insert and the aging time to 800 seconds.
<sysname> system-view [sysname] slb [sysname-slb] persistence 1 test [sysname-slb-persistence-1] type cookie-insert aging-time 800 [sysname-slb-persistence-1] cookie-name abc
Run the display slb persistence command to view the sticky session profile information of the current system.
<sysname> display slb persistence Persistence profile information(total 1) ---------------------------------------------------------------------------------------------------- Persistence Name :test Persistence ID :0 Persistence Type :cookie-insert Persistence Aging-time :800 Persistence App-cookie :abc //When the sticky session mode is cookie-insert, cookie-passive or cookie-rewrite, the name of inserted cookie can be specified.
Table 1 shows the description of the display slb persistence command output.
Item |
Description |
|---|---|
Persistence Name |
Name of a sticky session profile. This parameter is set using the persistence command. |
Persistence ID |
ID of a sticky session profile. This parameter is set using the persistence command. |
Persistence Type |
Sticky session mode. The default mode is Source IP. |
Persistence Aging-time |
Aging time of the sticky session node:
|
Persistence App-cookie |
Name of the cookie carrying sticky session. |