Last updated：2021-05-26 16:59:41
Session persistence enables SLB to send requests from the same IP address or Classless Inter-Domain Routing (CIDR) block to the same backend server. By default, SLB sends different requests to different backend servers.
Layer 4 forwarding supports a simple session persistence mechanism. You can set a threshold for session persistence. After the threshold is reached, SLB closes the current connection if no new requests arrive.
HTTP/HTTPS listening can use the following modes for session persistence: inset cookie and rewrite cookie.
You can specify a session persistence timeout period. SLB sets a cookie for a client by inserting the SERVERID and session persistence timeout period in the first HTTP/HTTPS response packet. Before the timeout period expires, SLB forwards all requests from the same client to the same backend server. SLB does not send the cookie to the backend server. In other words, the backend server does not need to know the SERVERID and the session persistence timeout period.
You can set a cookie keyword and value to insert to an HTTP/HTTPS response from a backend server as required. The session persistence time for the cookie must be maintained on the backend server. When SLB receives a response, it rewrites the cookie based on certain rules. When SLB receives a request that carries the new cookie keyword and value, SLB sends the new cookie keyword and value to the backend server.
Assume that a client is using HTTP/1.1 and Connection:keep-alive is set in the header. When session persistence is disabled, can the client continue to access the same backend server through SLB?
An HTTP keep-alive connection (persistent connection) is established between the client and SLB. If session persistence is not enabled, SLB distributes the next request from the client based on the round robin algorithm.
We recommend that you enable session persistence.
Assume that a client has initiated an access request, the transport layer protocol is TCP, and persistent connection is enabled. If source IP-based session persistence is not enabled, will the second request from the client be sent to the same backend server?
Answer: The request may not be sent to the same backend server.
Based on the Layer 4 implementation mechanism, if the persistent connection is not closed when the second request arrives, the request is sent to the same backend server. If the connection is already closed because of a network reboot or connection timeout event, the request may be scheduled to another backend server. By default, the global persistent connection timeout period is 900 seconds. If no requests arrive during the period, SLB will close the connection.
Did you find the above information helpful?
Please give us your feedback.
Thank you for your feedback.