Configuring Persistence Based on HTTP Cookies

The Citrix NetScaler initially selects a server by using a load balancing method. With persistence configured, enabling the NetScaler to send any subsequent client requests to the selected server, the server can access state information for that client. If persistence is configured, it overrides the load balancing methods once the server has been selected. If the configured persistence applies to a service that is down, the NetScaler uses the load balancing methods to select a new service, and the new service becomes persistent for subsequent requests from the client. If the state of the selected service is “out of service”, it continues to serve the outstanding requests, but it does not allow new requests or connections. After the shutdown period elapses, no new requests or connections are directed to the service and the existing connections are closed.

The NetScaler adds an HTTP cookie into the Set-Cookie header field of the HTTP response. The cookie contains information about the service where the HTTP requests must be sent. The client stores the cookie and includes it in all subsequent requests. The NetScaler uses this cookie to select the service for subsequent requests. You can use this persistence on virtual servers of type HTTP or HTTPS.

The NetScaler inserts the cookie NSC_XXXX=<ServiceIP ><ServicePort> where:

  • NSC_XXXX is the virtual server ID that is derived from the virtual server name.
  • ServiceIP is a representation of the IP address of the service.
  • ServicePort is a representation of the port of the service.
    ServiceIP and ServicePort are encrypted and inserted. When the NetScaler receives a cookie, it decrypts the cookie. If the client is not allowed to store the HTTP cookie, the subsequent requests do not have the HTTP cookie and persistence is not honored.

By default, the NetScaler sends an HTTP cookie with version 0, in compliance with the Netscape specification. The NetScaler can also send HTTP cookies with version 1, in compliance with RFC 2109.

You can configure a time-out value for persistence that is based on HTTP cookies. Note the following:

  • If HTTP cookie version 0 is used, the NetScaler inserts the absolute Coordinated Universal Time (GMT) of the cookie expiration time (the “expires” attribute of the HTTP cookie) that is calculated as the sum of the current GMT time on the NetScaler and the time-out value.
  • If an HTTP cookie version 1 is used, the NetScaler inserts a relative expiration time (“Max-Age” attribute of the HTTP cookie). In this case, the client software calculates the actual expiration time.
    Most client software currently installed (Microsoft Internet Explorer and Firefox browsers) understand HTTP cookie version 0; however, some HTTP proxies understand HTTP cookie version 1.

When you set the time-out value to 0, the NetScaler does not specify the expiration time regardless of the HTTP cookie version used. The expiration time depends on the client software and such cookies are not valid when the software is shut down. This persistence type does not consume any NetScaler resources. Therefore, it can accommodate an unlimited number of persistent clients.

To configure persistence based on HTTP Cookie, in the Persistence list, select COOKIEINSERT.

Get the most powerful Persistence Load Balancer here.

It’s powerful!