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 issoftdown
ordown
, 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 as the basis for server selection.
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-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