1. Strong load resistance. Strong load resistance and high performance, up to 60% of F5 hardware; The consumption of memory and CPU resources is relatively low
2. Working in the network layer 4, it is forwarded through the VRRP protocol (only for distribution). The specific traffic is handled by the Linux kernel, so there is no traffic.
2. Good stability and reliability, with perfect hot standby scheme; (e.g. LVS + kept)
3. It has a wide range of applications and can load balance all applications;
4. Regular processing is not supported, and dynamic and static separation cannot be performed.
5. Support load balancing algorithms: RR (round robin), WRR (weighted round robin), LC (minimum connection), WLC (minimum weight connection)
6. Complex configuration, great dependence on the network and high stability.
1. Working on layer 7 of the network, you can do some diversion strategies for HTTP applications, such as domain name and directory structure;
2. Nginx has little dependence on the network. Theoretically, if it can ping, it can perform the load function;
3. The installation and configuration of nginx are relatively simple and easy to test;
4. It can also bear high load pressure and is stable. Generally, it can support more than 10000 concurrent operations;
5. The health check of the back-end server only supports the detection through the port, not through the URL.
6. The asynchronous processing of requests by nginx can help the node server reduce the load;
7. Nginx can only support HTTP, HTTPS and email protocols, so it has a small scope of application.
8. The direct holding of session is not supported, but it can be through IP_ Hash to solve The support for big request header is not very good,
9. Support load balancing algorithms: Round Robin, weight Round Robin and IP hash
10. Nginx can also serve as a web server, i.e. cache function.
1. Support two proxy modes: TCP (layer 4) and HTTP (layer 7), and support virtual host;
2. It can supplement some shortcomings of nginx, such as session retention, cookie guidance and so on
3. Support URL detection and back-end server problem detection will be very helpful.
4. More load balancing strategies such as dynamic round robin, weighted source hash, weighted URL hash and weighted parameter hash have been implemented
5. In terms of efficiency, haproxy has better load balancing speed than nginx.
6. Haproxy can load balance mysql, detect and load balance backend DB nodes.
9. Support load balancing algorithms: Round Robin, weight Round Robin, source, RI and RDP cookie
10. You cannot be a web server, that is, a cache.
The three mainstream software load balancers are applicable to business scenarios
1. At the initial stage of website construction, nigix / haproxy can be selected as reverse proxy load balancing (or load balancing can not be selected if the traffic is small), because its configuration is simple and its performance can meet the general business scenarios. If considering that the load balancer has a single point problem, nginx + kept / haproxy + kept can be used to avoid the single point problem of the load balancer itself.
2. After the website has developed to a certain extent, LVS can be used to improve stability and forwarding efficiency. After all, LVS is more stable and forwarding efficiency than nginx / haproxy. However, the maintenance of LVS will have higher requirements for maintenance personnel and higher investment costs.
Note: comparison between niginx and haproxy: niginx supports seven layers, with the largest number of users and reliable stability. Haproxy supports four layers and seven layers, supports more load balancing algorithms, supports session saving, etc. The specific selection depends on the use scenario. At present, the number of users of haproxy is also increasing because it makes up for some shortcomings of niginx
Several important factors to measure the quality of load balancer
1. Session rate: number of requests processed per unit time
2. Session concurrency capability: concurrent processing capability
3. Data rate: data processing capacity
According to the official test statistics, the maximum number of requests processed by haproxy per unit time is 20000, 40000-50000 concurrent connections can be maintained at the same time, and the maximum data processing capacity is 10Gbps. Based on the above, haproxy is a load balancing and reverse proxy server with superior performance.
Summarize the main advantages of haproxy
1、 It is free and open source, and its stability is also very good. This can be seen from some small projects I have done. Single haproxy also runs well, and its stability is comparable to that of LVS;
2、 According to the official documents, haproxy can run full 10Gbps new benchmark of haproxy at 10Gbps using myricom’s 10GbE NICs (myri-10g PCI Express), which is also amazing as software level load balancing;
3、 Haproxy can be used as mysql, mail or other non web load balancing. We often use it as MySQL (read) load balancing;
4、 It comes with a powerful page to monitor the server status. In the actual environment, we use Nagios for email or SMS alarm, which is also one of the reasons why I like it very much;
The following configuration files for haproxy are explained in detail: