ADC

Least connection method

When a virtual server is configured to use the least connection load balancing algorithm (or method), it selects the service with the fewest active connections. This is the default method, because, in most circumstances, it provides the best performance.

For TCP, HTTP, HTTPS, and SSL_TCP services, the Citrix ADC appliance includes the following connection types in its list of existing connections:

  • Active connections to a service. Connections representing requests that a client has sent to the virtual server and that the virtual server has forwarded to a service. For HTTP and HTTPS services, active connections represent only those HTTP or HTTPS requests that have not yet received a response.
  • Waiting connections in the surge queue. Any connections to the virtual server that are waiting in a surge queue and have not yet been forwarded to a service. Connections can build up in the surge queue at any time, for any of the following reasons:
    • Your services have connection limits, and all services in your load balancing configuration are at that limit.
    • The surge protection feature is configured and has been activated by a surge in requests to the virtual server.
    • The load-balanced server has reached an internal limit and therefore does not open any new connections. (For example, an Apache server’s connection limit is reached.)

When a virtual server uses the least connection method, it considers the waiting connections as belonging to the specific service. Therefore, it does not open new connections to those services.

For UDP services, the connections that the least connection algorithm considers include all sessions between the client and a service. These sessions are logical, time-based entities. When the first UDP packet in a session arrives, the Citrix ADC appliance creates a session between the source IP address and port and the destination IP address and port.

For Real-Time Streaming Protocol (RTSP) connections, the Citrix ADC appliance uses the number of active control connections to determine the lowest number of connections to an RTSP service.

The following example shows how a virtual server selects a service for load balancing by using the least connection method. Consider the following three services:

  • Service-HTTP-1 is handling 3 active transactions.
  • Service-HTTP-2 is handling 15 active transactions.
  • Service-HTTP-3 is not handling any active transactions.

The following diagram illustrates how the Citrix ADC appliance forwards incoming requests when using the least connection method.

Figure 1. Mechanism of the Least Connections Load Balancing Method

LB-least-connection

In this diagram, the virtual server selects the service for each incoming connection by choosing the server with the fewest active transactions.

Connections are forwarded as follows:

  • Service-HTTP-3 receives the first request, because it is not handling any active transactions.

    Note: The service with no active transaction is selected first.

  • Service-HTTP-3 receives the second and third requests because the service has the next least number of active transactions.

  • Service-HTTP-1 receives the fourth request because Service-HTTP-1 and Service-HTTP-3 have the same number of active transactions, the virtual server uses the round robin method to choose between them.

  • Service-HTTP-3 receives the fifth request.

  • Service-HTTP-1 receives the sixth request, and so on, until both Service-HTTP-1 and Service-HTTP-3 are handling the same number of requests as Service-HTTP-2. Then, the Citrix ADC appliance starts forwarding requests to Service-HTTP-2 when it is the least loaded service or its turn comes up in the round robin queue.

    Note: If connections to Service-HTTP-2 close, it might get new connections before each of the other two services has 15 active transactions.

The following table explains how connections are distributed in the three-service load balancing setup described earlier.

Incoming Connection Service Selected Current Number of Active Connections Remarks
Request-1 Service-HTTP-3; (N = 0) 1 Service-HTTP-3 has the fewest active connections.
Request-2 Service-HTTP-3; (N = 1) 2 Service-HTTP-3 has the fewest active connections.
Request-3 Service-HTTP-3; (N = 2) 3 -
Request-4 Service-HTTP-1; (N = 3) 4 Service-HTTP-1 and Service-HTTP-3 have the same number of active connections.
Request-5 Service-HTTP-3; (N = 3) 4 Service-HTTP-1 and Service-HTTP-3 have the same number of active connections.
Request-6 Service-HTTP-1;(N = 4) 5 -
Request-7 Service-HTTP-3; (N = 4) 5 -
Request-8 Service-HTTP-1; (N = 5) 6 -

Service-HTTP-2 is selected for load balancing when it completes its active transactions and the current connections to it close, or when the other services (Service-HTTP-1 and Service-HTTP-3) have 15 or more connections each.

The Citrix ADC appliance can also use the least connection method when weights are assigned to services. It selects a service by using the value (Nw) of the following expression:

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

The following example shows how the Citrix ADC appliance selects a service for load balancing by using the least connection method when weights are assigned to services. In the preceding example, suppose Service-HTTP-1 is assigned a weight of 2, Service-HTTP-2 is assigned a weight of 3, and Service-HTTP-3 is assigned a weight of 4. Connections are forwarded as follows:

  • Service-HTTP-3 receives the first because the service is not handling any active transactions.

    Note: If the services are not handling any active transactions, the Citrix ADC appliance uses the round robin method regardless of the weights assigned to each of the services.

  • Service-HTTP-3 receives the second, third, fourth, fifth, sixth, and seventh requests because the service has the lowest Nw value.

  • Service-HTTP-1 receives the eighth request. Because Service-HTTP-1 and Service-HTTP-3 now have the same Nw value, the appliance performs load balancing in a round robin manner. Therefore, Service-HTTP-3 receives the ninth request.

The following table explains how connections are distributed on the three-service load balancing setup that is described earlier.

Request Received Service Selected Current Nw (Number of active transactions) * (10000 / weight) value Remarks
Request-1 Service-HTTP-3; (Nw = 0) Nw = 2500 Service-HTTP-3 has the lowest Nw value.
Request-2 Service-HTTP-3; (Nw = 2500) Nw = 5000
Request-3 Service-HTTP-3; (Nw = 5000) Nw = 7500
Request-4 Service-HTTP-3; (Nw = 7500) Nw = 10000
Request-5 Service-HTTP-3; (Nw = 10000) Nw = 12500
Request-6 Service-HTTP-3; (Nw = 12500) Nw = 15000
Request-7 Service-HTTP-1; (Nw = 15000) Nw = 20000 Service-HTTP-1 and Service-HTTP-3 have the same Nw values
Request-8 Service-HTTP-3; (Nw = 15000) Nw = 17500

Service-HTTP-2 is selected for load balancing when it completes its active transactions or when the Nw value of other services (Service-HTTP-1 and Service-HTTP-3) is equal to 50000.

The following diagram illustrates how the Citrix ADC appliance uses the least connection method when weights are assigned to the services.

Figure 2. Mechanism of the Least Connections Load Balancing Method when Weights are Assigned

Assign weights and methods

To configure the least connection method, see Configuring a Load Balancing Method that Does Not Include a Policy.

Least connection method