Session persistence forwards requests that meet the same session persistence conditions to the same backend server within a specified period, so that applications that require session persistence work properly and session continuity and stability are maintained.
After session persistence is configured, if the interval between the client's current request and previous request is less than or equal to the session persistence timeout, the requests are considered part of the same session. The request is still forwarded to the backend server that handled the previous request, and the session persistence timeout is reset. If the interval exceeds the session persistence timeout, the request is treated as a new session, and the system reselects a backend server according to the load balancing algorithm.
ANS load balancing supports the following session persistence methods:
Source IP address-based session persistence: During the session persistence period, all connections with the same source address are forwarded to the same backend server. Both L4 and L7 load balancing support this method.
Cookie-based session persistence: When a client accesses the service for the first time, load balancing generates and inserts a cookie into the response. Subsequent requests that carry the same cookie and are within the session persistence timeout are routed to the same backend server. This method is supported only for L7 load balancing.
The cookie-based session persistence process is as follows:
Backend A according to the load balancing algorithm.Backend A processes the request and returns the response to Envoy.Set-Cookie; the client stores the cookie.Backend A.