Comparison of mainstream load balancing services with LVS, HAProxy and Nginx

 
 

1. Advantages of LVS:

1. Strong anti-load capability, because the logic of lvs working mode is very simple, and it works at the 4th layer of the network only for request distribution without traffic, so there is basically no need to think too much about efficiency. In the lvs in my hand, there is only one problem: the balancer loses packets in a short period of time when the concurrency is the highest. According to the analysis, it is a network problem, that is, the carrying capacity of the network card or linux2. There is basically no consumption of cpu. 

2. Low configurability, which is usually a major disadvantage, but also a major advantage, because there are not many configurable options, so in addition to increasing or decreasing servers, it is not necessary to touch it frequently, which greatly reduces human error. probability.

3. The work is stable. Because of its strong anti-load ability, it is logical to have high stability. In addition, various lvs have a complete dual-machine hot backup solution, so there is no need to worry about the balancer itself. The problem is that the node fails. If it is, lvs will automatically judge, so the system as a whole is very stable.

4. No traffic, as mentioned above. lvs only distributes requests, and the traffic does not go out from itself, so it can be used to do some line shunting. No traffic also keeps the balancer's IO performance from being affected by heavy traffic.

5. It can basically support all applications, because lvs works at layer 4, so it can do load balancing for almost all applications, including http, database, chat room, etc.

Second, LVS features:

   1. Strong anti-load capability, using IP load balancing technology, only for distribution, so LVS itself does not generate much traffic;

   2. It has good stability and reliability, and has its own perfect hot backup solution; (such as: LVS+Keepalived)

   3. It has a wide range of applications, and can do load balancing for all applications;

   4. Regular processing is not supported, and dynamic and static separation cannot be performed.


Four algorithms are commonly used:

   1.rr: round call, assigned to the back-end server in turn;

   2.wrr: The weight is called in rotation, which is allocated according to the load of the back-end server;

   3.lc: Minimum connection, allocated to the server with the least established connection;

   4.wlc: The connection with the least weight, which is allocated according to the processing capacity of the back-end server.


3. HAProxy features:

   1. Support two proxy modes: TCP (layer four) and HTTP (layer seven), support virtual host;

   2. Simple configuration, support url detection of backend server status;

   3. It is only used for load balancing software. In the case of high concurrency, the processing speed is higher than nginx;

   4. The TCP layer is mostly used for Mysql slave (read) server load balancing.


Four commonly used algorithms :

   1.roundrobin: polling, assigned to the back-end server in turn;

   2.static-rr: allocated according to the performance of the backend server;

   3.leastconn: the smallest connector will be processed first;

   4.source: According to the request source IP, similar to Nginx's IP_Hash.


Fourth, Nginx features:

   1. It works on the 7th floor, and can process regular rules; (such as: diverting domain names and directories)

   2. The configuration is simple, and the load function can be performed if it can be pinged. The status of the back-end server can be detected through the port, and url detection is not supported;

   3. Anti-high concurrency, using the epoll network model to process customer requests;

   4. Only support HTTP and EMail, and the application scope is relatively small;

   5.nginx is mainly an HTTP and reverse proxy server, with low system resource consumption.


Four algorithms are commonly used:

   1.RR: (default) polling, assigned to the back-end server in turn;

   2.weight: allocated according to the performance of the backend server;

   3. ip_hash: Each request is allocated according to the hash result of accessing the ip, and the concurrency hour is appropriate to solve the session problem;

   4. fair: (extension strategy), the nginx kernel will not be compiled by default, judge the load situation according to the response time of the back-end server, and select the lightest one for processing.

Guess you like

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