[Load balancing algorithms supported by haproxy]

Currently, the load balancing algorithms supported by haproxy are as follows:

 

1, roundrobin  simple polling

Represents simple round-robin, where each server is used in turn based on weights, which is the smoothest and fairest algorithm when the processing time of the servers is equally distributed. The algorithm is dynamic, and the weights for servers with slow instance startups are adjusted on the fly.

 

2. leastconn has the  least number of connections first

The server with the fewest connections receives connections first. leastconn is recommended for long-session services, such as LDAP, SQL, TSE, etc., and is not suitable for short-session protocols. Such as HTTP. The algorithm is dynamic, and the server weights for slow instance startups will be adjusted on the fly.

 

3. Static-rr  weight polling

Each server is used in turn according to the weight, similar to roundrobin, but it is static, which means that modifying permissions at runtime is invalid. Also, it has no limit on the number of servers.

This algorithm is generally not used;

 

4. Source  source IP hash

Hash the request source IP address, divide the total weight of available servers by the hash value, and assign according to the result. As long as the server is normal, the same client IP address always accesses the same server. If the result of the hash varies with the number of available servers, the client is directed to a different server;

 

This algorithm is generally used in Tcp mode where cookies cannot be inserted. It can also be used to provide the most efficient adhesion over the WAN for clients that refuse to use session cookies;

The algorithm is static by default, so it is invalid to modify the weight of the server at runtime, but the algorithm will be adjusted according to the change of "hash-type".

 

5, uri     URI Hazuki

Indicates hashing based on the left end of the requested URI (before the question mark), dividing the total weight of available servers by the hash value, and assigning based on the result. As long as the server is normal, the same URI address always accesses the same server. Generally used for proxy cache and anti-virus proxy to maximize the cache hit rate. This algorithm can only be used with HTTP backends;

 

This algorithm is generally used for back-end cache servers;

The algorithm is static by default, so it is invalid to modify the weight of the server at runtime, but the algorithm will be adjusted according to the change of "hash-type".

 

6. URL parameters specified by url_param  

Look for the URL parameter specified in <param> in the query string of the HTTP GET request, basically locking the request to a specific load balancer node using a specially crafted URL;

This algorithm is generally used to send the information of the same user to the same backend server;

The algorithm is static by default, so it is invalid to modify the weight of the server at runtime, but the algorithm will be adjusted according to the change of "hash-type".

 

7. hdr(name)  finds HTTP headers

Look up the HTTP header <name> in each HTTP request, the HTTP header <name> will be seen in each HTTP request and target a specific node;

If the header is missing or the header doesn't have any value, use roundrobin instead;

The algorithm is static by default, so it is invalid to modify the weight of the server at runtime, but the algorithm will be adjusted according to the change of "hash-type".

 

8. rdp-cookie (name) TCP request query and hash

Query and hash RDP cookie <name> for each incoming TCP request;

This mechanism is used in degenerate persistent mode, so that the same user or the same session ID is always sent to the same server. If there is no cookie, the roundrobin algorithm is used instead;

The algorithm is static by default, so it is invalid to modify the weight of the server at runtime, but the algorithm will be adjusted according to the change of "hash-type".

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326301729&siteId=291194637