linux server's LVS Nginx and HAProxy load balancer comparison summary

  • 2020-05-09 19:44:15
  • OfStack

LVS features:

1. Strong anti-load capability, IP load balancing technology is used for distribution only, so LVS itself does not generate much traffic;
2. Good stability and reliability, with perfect thermal standby plan; (e.g. LVS+Keepalived)
3. It has a wide application range and can do load balancing for all applications;
4. Regular processing is not supported, and static and static separation cannot be done.

Commonly used four algorithms:

1.rr: round call, which is allocated to the back-end server in turn;
2.wrr: the weight round is called, which is distributed 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 minimum connection weight is allocated according to the processing capacity of the back-end server.
You can use ipvsadm and p (persistence) to keep session. The default is 300/s

Nginx features:

1. Working on the 7th floor, you can deal with regular rules; (e.g. : separate domain names and directories)
2. Simple configuration, able to carry out load function with ping connection, able to detect the status of back-end server through the port, url detection is not supported;
3. Anti-high concurrency, epoll network model is adopted to process customer requests;
4. It only supports HTTP and EMail, and its application range is relatively small;
5.nginx is mainly HTTP and reverse proxy server with low system resource consumption.

Commonly used four algorithms:

1.RR :(default) polling and alternate allocation to back-end servers;
2.weight: allocation based on back-end server performance;
3.ip_hash: each request is allocated according to the result of accessing hash of ip, and the concurrency time is appropriate to solve the session problem;
4.fair (extension policy), nginx kernel will not be compiled by default, and the load will be judged according to the back-end server response time, and the lightest one will be selected for processing.

HAProxy features:

1. Support two proxy modes: TCP (layer 4) and HTTP (layer 7), which support virtual host;
1. Simple configuration, support url to detect the status of back-end server;
2. For load balancing software only, the processing speed is higher than nginx in high concurrency;
3. TCP layer is mostly used for load balancing of Mysql slave (read) servers.

Four common algorithms:

1.roundrobin: polling to be allocated to back-end servers in turn;
2. static-rr: allocation based on back-end server performance;
3.leastconn: minimum connection is preferred;
4.source: based on the request source IP, similar to IP_Hash for Nginx.
Why resolve the session session?

Load balancing environment, each user has access backend server may not be fixed, in some cases, is a must in 1 time with 1 users access to all the requests are assigned to the backend server with 1 to deal with, for example: e-commerce sites, such as user registration page, refresh the page 1, another one will be assigned to the backend server, the information on the page just now are all didn't, in this case, the allocation with 1 server processes the request is very important!

This is from the penguin thing blog

Related articles: