Nginx, LVS, HAproxy load balancing contrast

Nginx:

1, work at Layer 7 network, you can do some diversion policy for http applications, such as for the domain name, the directory structure
2, Nginx less dependent on the network, in theory, be able to ping can be deposited in the function
3, Nginx installation configuration is relatively simple, it is very easy to test
4, can also bear a higher load pressure and stable, Nginx to solve the problem of the birth of c10k
5, check the health of the back-end server supports only be detected through the port, it is not supported by url detected
6, Nginx asynchronous processing request node server can help reduce the load pressure of
7, Nginx only support http, https and Email protocols, so that the scope of small
8, does not support direct Session held, but can ip_hash to solve, support is not very good for Bigrequestheader
9, Nginx Web server can do that is Cache function.

LVS:

1, an anti-load capacity, high performance, can achieve F5 60% of memory and cpu resource consumption is relatively low
2, work in the network layer 4, by the VRRP (only do agent used), the specific flow rate is liunx kernel processed, so no flow.
3, stability, reliability, itself has a perfect Redundancy (+ Keepalived the LVS)
. 4, does not support regular process, do not separate movement
5, support a variety of load balancing algorithms: rr (polling), WRR (Weighted polling), LC (minimum connection), WLC (weighted least connections)
6, the configuration is relatively complex, dependent on the network is relatively large, high stability.

LVS There are four operating modes:

  • nat NAT
  • dr direct route
  • tun tunnel
  • full-nat

HAproxy:

1, the agent supports two modes: TCP (four) and HTTP (seven), support for virtual hosts
2, Nginx can complement some shortcomings such as Session remains, Cookie guide, etc.
3, to support the back-end server url detect problems the detection will be a good help.
4, more load balancing strategies such as: dynamic weighted round robin, weighted source address hash, hash Weighted Weighted URL parameters hash has been achieved.
5, purely in terms of efficiency from the HAproxy more than Nginx has better load balancing
6, HAproxy can MYsql load balancing, the DB back-end nodes to detect and load balancing
7, supports load balancing algorithms: round robin, weighted Round Robin, keep the source address, request URL, according to Cookie
8, can not do a Web server that is Cache.

Three major software load balancer suitable production scenarios:

1, the beginning of the construction site, you can choose Nginx, HAproxy as a reverse proxy load balancing (you can choose not to load balance traffic is not significant) because of its simple configuration, performance can meet the general business scenario. If you take into account the load balancer is a single point of failure problem, Nginx + Keepalived avoid load balancer itself of a single point can be used.
2, the website concurrent to a certain extent, in order to improve the stability and efficiency of forwarding, you can use LVS, after all, LVS / HAproxy to be more stable than Nginx, forwarding efficiency is high.

Guess you like

Origin www.cnblogs.com/shunzi115/p/12664086.html