algorithm

This command specifies the server selection algorithm.

Syntax

algorithm { first-alive | hash | least-connections | round-robin | weighted-least-connections | weighted-round-robin }

Parameters

first-alive
Uses the concept of a primary server and backup servers. When the health state of the primary server is up, all connections are forwarded to this server. When the health state of the primary server is softdown or down, connections are forwarded to backup servers. The primary server is the first server in the members list.
hash
Uses the IP address of the client or HTTP header value as the basis for server selection.
With an HTTP header, use the load-balancer-hash-header command to identify the header to read. This command is available for only the following services.
  • Multi-Protocol Gateway
  • Web Service Proxy

With the hash algorithm, the same client is served by the same server. Use this algorithm only when clients access applications that require the storage of server-side state information, such as cookies. Hashing algorithms cannot ensure even distribution.

least-connections
Maintains a record of active server connections and forward a new connection to the server with the least number of active connections.
round-robin
Maintains a list of servers and forwards a new connection to the next server on the list. This setting is the default value.
weighted-least-connections
Maintains a record of the number of active server connections and forwards new connections to the server with the least number of current connections. The calculation is in proportion to the weight of each server.

This algorithm requires the Application Optimization feature.

weighted-round-robin
Maintains a weighted list of servers and forwards new connections in proportion to the weight (or preference) of each server.

Guidelines

The algorithm command specifies the server selection algorithm. A request to connect to a load balancer group results in a server with a health state of up selected from the pool according to the algorithm. The algorithm provides a method for selecting which server with a health state of up receives an incoming client request.

Examples

  • Specify that server selection uses the first-alive algorithm.
    # algorithm first-alive
  • Specify that server selection uses the least-connections algorithm.
    # algorithm least-connections
  • Specify that server selection uses the weighted-round-robin algorithm.
    # algorithm weighted-round-robin