All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Session persistence

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 session persistence

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.

Layer 7 session persistence

HTTP/HTTPS listening can use the following modes for session persistence: inset cookie and rewrite cookie.

Insert 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.

Rewrite cookie

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.

Relationship between persistent connections and session persistence

Scenario 1: HTTP Layer 7 service

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?

Answer: No.

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.

Scenario 2: TCP Layer 4 service

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.

On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback