Server Load Balancing : Configuring persistence rules
 
Configuring persistence rules
Persistence rules identify traffic that should not be load balanced, but instead forwarded to the same backend server that has seen requests from that source before. Typically, you configure persistence rules to support server transactions that depend on an established client-server session, like e-commerce transactions or SIP voice calls.
Persistence rules are evaluated before load balancing rules. If the packets received by the ADC match the session properties you configure for the persistence rule, the packets are forwarded to the server that established the connection, and load balancing rules are not applicable.
Table 7 describes the predefined persistence rules. You can get started with these commonly used persistence methods or create custom objects.
Table 7: Predefined persistence rules
Predefined
Description
LB_PERSIS_SIP
Persistence based on IP address or subnet.
The system selects the backend server for a client IP’s first request using the method specified in the virtual server configuration and then stores the relationship between client IP and server in a table. It uses the mapping in the table to forward subsequent requests from the same IP address or subnet to the same backend server.
LB_PERSIS_CONSISTENT_SIP
Persistence based on a hash of source IP.
The system uses an algorithm to calculate a hash value for the IP address of the client making an initial request. It then maps this value to the selected backend server and uses the mapping table to forward subsequent requests that generate the same hash value to the same backend server.
LB_PERSIS_HASH_SRC_ADDR_PORT
Persistence based on a hash that includes source IP and port.
The system uses an algorithm to calculate a hash value for the IP address and port of an initial client request. It then maps this value to the selected backend server and uses the mapping table to forward subsequent requests that generate the same hash value to the same backend server.
LB_PERSIS_HASH_COOKIE
Persistence based on a cookie provided by the backend server.
The system uses an algorithm to calculate a hash value for the cookie provided by the backend server. It then maps this value to the selected backend server and uses the mapping table to forward subsequent requests that generate the same hash value to the same backend server.
LB_PERSIS_SSL_SESS_ID
Persistence based on the SSL session ID.
If the initial client request has an SSL session ID, the system sends all subsequent sessions with the same SSL session ID to the same backend server.
Before you begin:
You must have a good understanding and knowledge of the applications that require persistent sessions and the methods that can be used to identify application sessions.
You must have Read-Write permission for Load Balance settings.
After you have configured a persistence rule, you can select it in the virtual server configuration.
To configure a persistence rule:
1. Go to Server Load Balance > Virtual Server.
2. Click the Persistence tab.
3. Click Add to display the configuration editor.
4. Give the rule a name, select the type, and specify rule settings as described in Table 8.
5. Save the configuration.
 
Table 8: Persistence rule guidelines
Settings
Guidelines
Source Address
Source Address
Persistence is based on source IP address.
The system selects the backend server for a client’s first request using the method specified in the virtual server configuration and then stores the relationship between the client IP address and the selected backend server in a table. It uses the mapping table to forward subsequent requests from the client IP address to the same backend server.
Timeout
Server-side session timeout. Specifies the maximum amount of time between requests. That is, when the time that has elapsed since the system last received a request from the client IP is greater than the timeout, the system does not use the mapping table to forward the request. Instead, it again selects the server using the method specified in the virtual server configuration.
Subnet Mask Bits (IPv4)
Number of bits in a subnet mask to specify a network segment that should following the persistence rule.
For example, if IPv4 maskbits is set to 24, and the backend server A responds to a client with the source IP 192.168.1.100, server A also responds to all clients from subnet 192.168.1.0/24.
Subnet Mask Bits (IPv6)
Number of bits in a subnet mask to specify a network segment that should following the persistence rule.
Source Address Hash
Source Address Hash
Persistence is based on a hash of the IP address of the client making an initial request.
Source Address-Port Hash
Source Address-Port Hash
Persistence is based on a hash of the IP address and port of an initial client request.
HTTP Header Hash
HTTP Header Hash
Persistence is based on a hash of the specified header value found in an initial client request.
Keyword
A value found in an HTTP header.
HTTP Request Hash
HTTP Request Hash
Persistence is based on a hash of the specified URL parameter in an initial client request.
Keyword
A URL parameter.
Cookie Hash
Cookie Hash
Persistence is based on a hash of the cookie provided by the backend server.
Persistent Cookie
Persistent Cookie
Persistence is based on the cookie provided in the backend server response.
It forwards subsequent requests with this cookie to the original backend server.
If you do not specify a Cookie value for the server, the system uses the Keyword value to generate a cookie as described for Insert Cookie.
Keyword
Backend server cookie name.
Timeout
Server-side session timeout. Specifies the maximum amount of time between requests. That is, when the time that has elapsed since the system last received a request with the cookie is greater than the number of seconds specified by the timeout, it does not forward the request based on the cookie. Instead, it again selects the server using the method specified in the virtual server configuration.
Insert Cookie
Insert Cookie
Persistence is based on a cookie inserted by the FortiADC system.
The system inserts a cookie whose name is the value specified by Keyword and whose value is the server's Cookie value and expiration date (if the client does not already have a cookie). If the server generates a cookie with the same name, the cookie’s value is replaced with the server's Cookie value and expiration date.
For example, if the value of Keyword is sessid and the server Cookie value is rs1, FortiADC sends the cookie sessid=rs1|U6iFN to the client, where U6iFN is the expiration date as a base64 encoded string.
Keyword
Specifies the cookie name.
Timeout
Server-side session timeout. Specifies the maximum amount of time between requests. That is, when the time that has elapsed since the system inserted the cookie is greater than the number of seconds specified by Timeout, it does not forward the request based on the cookie. Instead, it again selects the server using the method specified in the virtual server configuration.
Rewrite cookie
Rewrite Cookie
Persistence is based on the cookie provided in the backend server response, but the system rewrites the cookie.
The system checks the HTTP response for a Set-Cookie: value that matches the value specified by Keyword. It replaces the value specified by the keyword with the server’s Cookie value.
For example, the value of Keyword in the persistence configuration is sessid. The Cookie value for a server in the pool is rs1. After an initial client request, the response from the server contains Set-Cookie: sessid=666, which FortiADC changes to Set-Cookie: sessid=rs1. FortiADC uses this rewritten value to forward subsequent requests to the same backend server as the original request.
Keyword
Specifies a Set-Cookie: value to match.
Embedded Cookie
Embedded Cookie
Persistence is based on the cookie provided in the backend server response.
Like Rewrite Cookie, the system checks the HTTP response for a Set-Cookie: value that matches the value specified by Keyword in the persistence configuration. However, it preserves the original value and adds the server’s Cookie value and a ~ (tilde) as a prefix.
For example, the value of Keyword is sessid. The Cookie value for a server in the pool is rs1. After an initial client request, the response from the server contains Set-Cookie: sessid=666, which the system changes to Set-Cookie: sessid=rs1~666. It uses this rewritten value to forward subsequent requests to the same backend server as the original request.
Keyword
Specifies a Set-Cookie: value to match.
RADIUS Attribute
RADIUS Attribute
Persistence is based on a specified RADIUS attribute.
The system selects the backend server for a client IP’s first request using the method specified in the virtual server configuration and then stores the relationship between the value of the specified RADIUS attribute and the backend server in a table. It uses the mapping in the table to forward subsequent requests with the attribute value to the same backend server.
Keyword
RADIUS attribute.
Timeout
Server-side session timeout. Specifies the maximum amount of time between requests. That is, when the time that has elapsed since the system last received a request with the specified attribute value is greater than the number of seconds specified by Timeout, the system does not use the mapping table to forward the request. Instead, it again selects the server using the method specified in the virtual server configuration.
Match across servers
Allow clients to continue to access the same backend server through different virtual servers for the duration of a session.
SSL Session ID
SSL Session ID
Persistence is based on SSL session ID.
If the initial client request has an SSL session ID, the system sends all subsequent sessions with the same SSL session ID to the same backend server.
Timeout
Server-side session timeout. Specifies the maximum amount of time between requests. That is, when the time that has elapsed since the system last received a request with the SSL session ID is greater than the number of seconds specified by Timeout, the system does not use the mapping table to forward the request. Instead, it again selects the server using the load balancing method.