Session persistence

LBaaS v2 supports session persistence on virtual IPs. Session persistence is a method of load balancing that forces multiple client requests of the same protocol to be directed to the same node. This feature is commonly used with many web applications that do not share application states between pool members.

The types of session persistence supported with the HAProxy driver include the following:

  • SOURCE_IP
  • HTTP_COOKIE
  • APP_COOKIE

Using the SOURCE_IP persistence type configures HAProxy with the following settings within the backend pool configuration:

stick-table type ip size 10k 
stick on src

The first time a client connects to the virtual IP, HAProxy creates an entry in a sticky table based on the client's IP address and sends subsequent connections from the same IP address to the same backend pool member. Based on the configuration, up to 10,000 sticky entries can exist in the sticky table. This persistence method can cause load imbalance between pool members if users connect from behind a proxy server that misidentifies multiple clients as a single address.

Using the HTTP_COOKIE persistence type configures HAProxy with the following settings within the backend pool configuration:

cookie SRV insert indirect nocache 

The first time a client connects to the virtual IP, HAProxy balances the connection to the next pool member in line. When the pool member sends its response, HAProxy injects a cookie named SRV into the response before sending it to the client. The value of the SRV cookie is a unique server identifier. When the client sends subsequent requests to the virtual IP, HAProxy strips the cookie from the request header and sends the traffic directly to the pool member identified in the cookie. This persistence method is recommended over source IP persistence, as it is not reliant on the IP address of the client. However, it may not be compatible with all clients.

Using the APP_COOKIE persistence type configures HAProxy with the following settings within the backend pool configuration:

appsession <CookieName> len 56 timeout 3h 

When an application cookie is defined in a backend configuration, HAProxy will check server responses for the cookie, stores its value in a table, and associates it with the server's identifier. Up to 56 characters from the value will be retained. On subsequent client connections, HAProxy will look for the cookie in the client's request. If a known value is found, the client is directed to the pool member associated with the value. Otherwise, the round-robin load balancing algorithm is applied. Cookies are automatically removed from memory when they have gone unused for a duration longer than three hours.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset