Citrix Netscaler Load Balancing Algorithms

Least Connection Method

When NetScaler is configured to use the least connection method, it selects the service with the least number of active connections to ensure that the load of the active requests is balanced on the services. This method is the default load balancing method because it provides the best performance. For TCP, HTTP, HTTPS, and SSL_TCP services.

Using Weights with the Least Connection Method

The NetScaler also performs load balancing by using the number of connections when weights are assigned to services. The NetScaler selects the service by using the value (Nw) of the following expression:

Nw = (Number of active transactions) * (10000 / weight)

Round Robin Method

When the NetScaler is configured to use the round robin method, it rotates incoming requests to the managed servers, regardless of the load. For example, the first request is sent to Service-HTTP-1, the second to Service-HTTP-2, the third to Service-HTTP-3, and so forth. When requests have been sent to all of the servers, the cycle begins again from Service-HTTP-1.
A NetScaler also performs weighted round robin if different weights are assigned to the services. For example, Service-HTTP-1 is set to a weight of 2, Service-HTTP-2 to a weight of 3, and Service-HTTP-3 to a weight of 4, and the services are bound to Vserver-LB-1. The requests are delivered as follows:
  • Service-HTTP-1 receives the first request.
  • Service-HTTP-2 receives the second request.
  • Service-HTTP-3 receives the third request.
  • Service-HTTP-1 receives the fourth request.
  • Service-HTTP-2 receives the fifth request.
  • Service-HTTP-3 receives the sixth request.
  • Service-HTTP-2 receives the seventh request.
  • Service-HTTP-3 receives the eighth and ninth requests.

Least Response Time Method

When the NetScaler is configured to use the least response time method, it selects the service with the least number of active connections and the least average response time. You can configure this method for HTTP and Secure Sockets Layer (SSL) type of services only. The response time also called Time to First Byte, or TTFB is the time interval between sending a request packet to a service and receiving the first response packet from the service. The NetScaler uses response code 200 to calculate TTFB.

Using Weights with the Least Response Time Method

The NetScaler also performs load balancing by using the number of connections, TTFB, and weights if different weights are assigned to the services. The NetScaler selects the service by using the value (Nw) of the following expression:

Nw = (N) * (10000 / weight)

The following example shows how the NetScaler selects a service for load balancing by using the least response time method when weights are assigned on the services. In the preceding example, suppose Service-HTTP-1 is assigned a weight of 2, Service-HTTP-2 is assigned weight of 3, and Service-HTTP-3 is assigned weight of 4.
The NetScaler delivers the requests as follows:
  • Service-HTTP-3 receives the first request because it is not handling any active transaction.

    Note: If services are not handling any active transactions, the NetScaler selects them regardless of the weights assigned to them.

  • Service-HTTP-3 receives the second, third, fourth, and fifth requests because the service has the least Nw value.
  • Service-HTTP-2 receives the sixth request because the service has the least Nw value.
  • Service-HTTP-3 receives the seventh request because the service has the least Nw value.
  • Service-HTTP-2 receives the eighth request because the service has the least Nw value.
Service-HTTP-1 has the least weight and the Nw value is the highest. Therefore, the NetScaler does not select it for load balancing.

Least Response Time Method with Monitors

When the NetScaler is configured to use the least response time method with monitors, it selects the service with the least number of active transactions and the fastest average response time of monitors. With this load balancing method, the NetScaler uses the existing monitoring infrastructure. Therefore, before you use this method, you must bind application-specific monitors to each service and enable least response time method mode on these monitors. The NetScaler then makes load balancing decisions based on the response times received from the monitoring probes.
Least response time method with monitors can be used to select non-HTTP and non-HTTPS services unlike the least response time method without monitors. You can also use this method when several monitors are bound to a service. The vserver reads the response times of all monitors and calculates an average response time for each service. Monitors determine response times according to different protocols.

Using Weights with the Least Response Time Method

The NetScaler also performs load balancing by using the number of active transactions, response time, and weights, if different weights are assigned to the services. The NetScaler selects the service by using the value (Nw) of the following expression:

Nw = (N) * (10000 / weight)

Hash Methods

You can use hashing methods in a cache environment where a cache serves a wide range of content from the Internet or origin servers. Caching the requests reduces the request and response latency and ensures better resource utilization (CPU) at the cache. The NetScaler provides the following hashing methods:
  • URL hash method
  • Domain hash method
  • Destination IP hash method
  • Source IP hash method
  • Source IP Destination IP hash method
  • Source IP Source Port hash method
  • Call ID hash method
  • Token method

URL Hash Method

When the NetScaler is configured to use the URL hash method, it selects a service based on the hashed value of an incoming HTTP URL. The NetScaler caches the hashed value of the URL, and subsequent requests that use the same URL make a cache hit and are forwarded to the same service. By default, the NetScaler calculates the hash value based on the first 80 bytes of the URL. You must specify the Hash Length parameter to calculate a different URL value. If the NetScaler cannot accurately parse the incoming request, it uses the round robin method for load balancing.

Domain Hash Method

When the NetScaler is configured to use the domain hash method, it selects a service based on the hashed value of the domain name in the HTTP request. The domain name is taken either from the incoming URL or from the Host header of the HTTP request. If the domain name appears in both the URL and the Host header, the NetScaler gives preference to the URL.
If you configure domain name hashing and an incoming HTTP request does not contain a domain name, the NetScaler defaults to the round robin method for that request.
The hash value is calculated using the name length or hash length value, whichever is smaller. By default, the NetScaler calculates the hash value from the first 80 bytes of the domain name. To specify a different number of bytes in the domain name when calculating the hash value, use the Hash Length parameter.

Destination IP Hash Method

When the NetScaler is configured to use the destination IP hash method, it selects a service based on the hashed value of the destination IP address. You can use the subnet mask parameter to mask the destination IP address and then calculate the hash value. When the requests from different networks arrive at the NetScaler, it identifies the requests belonging to a subnet using the subnet mask and forwards the requests to the same server based on the hashed value. This method is appropriate for use with the cache redirection feature of theNetScaler.

Source IP Hash Method

When the NetScaler is configured to use the source IP hash method, it selects a service based on the hashed value of the client IPv4 or IPv6 address.

Source IP Destination IP Hash Method

When the NetScaler is configured to use the source IP destination IP hash method, it selects a service based on the hashed value of the source and destination IP addresses (either IPv4 or IPv6). Hashing is symmetric, so it yields the same value if the source and destination IP addresses are reversed. This ensures that all packets flowing from a particular client to the same destination are directed to the same server.

Source IP Source Port Hash Method

When the NetScaler is configured to use the source IP source port hash method, it selects the server based on the hash value of the source IP (either IPv4 or IPv6) and source port of the incoming request. This ensures that all packets on a particular connection are directed to the same server.

Call ID Hash Method

When the NetScaler is configured to use the call ID hash method, it selects the service based on the hash value of the call ID in the SIP header, so that a particular SIP session is directed to the same proxy server. This method is applicable for SIP load balancing.

Least Bandwidth Method

When the NetScaler is configured to use the least bandwidth method, it selects the service that is currently serving the least amount of traffic, measured in megabits per seconds (Mbps).

Using Weights with the Least Bandwidth Method

The NetScaler also performs load balancing by using the bandwidth and weights if different weights are assigned to the services. The NetScaler selects the service by using the value (Nw) of the following expression:

Nw = (N) * (10000 / weight)

Least Packets Method

When the NetScaler is configured to use the least packets method, it selects the service that is currently serving the least packets in the last 14 seconds second.

Using Weights with the Least Packets Method

The NetScaler also performs load balancing by using the number of packets and weights if different weights are assigned to the services. The NetScaler selects the service by using the value (Nw) of the following expression:

Nw = (N) * (10000 / weight)

Token Method

When the NetScaler is configured to use the token method, it selects a service based on the value of a token extracted from the client request. You can configure the location and size of the token. For subsequent requests with the same token, the NetScaler chooses the same server that handled the initial request. This method is content aware. This means that it operates differently for the TCP, HTTP, and HTTPS service types. For HTTP or HTTPS services, the token is found in the HTTP headers or the URL or the BODY using the configured expressions.

Custom Load Method

Generally, the NetScaler selects a service that is not handling any active transaction. If the services are handling active transactions, the NetScaler selects a service based on its load. A special type of monitor, known as a load monitor, calculates the load on each service in the network. The load monitors do not mark the state of a service; however, they take the service out of the load balancing decision. Custom load balancing is performed on server parameters such as CPU usage, memory, and response time.

Using Weights with the Custom Load Method

The NetScaler also performs load balancing by using the load on services, and weights if different weights are assigned to the services, weights are also used for load balancing. The NetScaler selects the service by using the value (Nw) of the following expression:

Nw = (N) * (10000 / weight)



KeywordsCitrix Netscaler Load Balancing Methods metric least connections hash roundrobin   Doc ID13201
OwnerScott B.GroupNetwork Services
Created2010-01-28 19:00:00Updated2015-01-15 13:45:41
SitesDCTeam, DoIT Staff, Network Services, Systems & Network Control Center, Systems Engineering
Feedback  2   3