Features and comparison of software-level Load balancer (LVS/haproxy/nginx)

Source: Internet
Author: User
Tags haproxy

The current development trend of the website for the use of network load balancing is as the scale of the website increases according to different stages to use different technologies:

One is through hardware. Common Hardware includes expensive NetScaler, F5, radware, array, and other commercial load balancers, it has the advantage of a professional maintenance team to maintain these services. The disadvantage is that the cost is too large. Therefore, it is not required for small network services for the time being; in addition, it is similar to LVS/haproxy and nginx's Linux-based open-source free Server Load balancer software policies, which are implemented at the software level, so the cost is very low, therefore, I also recommend that you use the second solution to implement your website's load balancing requirements.

Recently, a friend of Liu Xin (ziyu hexue) successfully launched the project, with PV reaching hundreds of millions of visits per day, the Front-End Server Load balancer/reverse proxy is implemented by haproxy + keepalived. The entire website is very stable; this strengthened my previous discussions with old boys about the well-designed architecture of the Website: nginx/haproxy + keepalived as the front-end Server Load balancer of the web, the backend MySQL database architecture adopts the One-master-multiple-slave, read/write splitting mode, and The LVS + keepalived mode.


Here, I also want to declare that many of my friends are worried about the stability of software-level Server Load balancer under the impact of high-concurrency traffic. The fact is that we have successfully launched many websites, their stability is also very good, and the possibility of downtime is very small, so I am working on the project, basically did not consider the high availability of the service level. I believe that everyone has a deep understanding of these software-level Server Load balancer software. Below I will explain their characteristics and applicable scenarios separately.

LVS: implements a high-performance, high-availability server using cluster technology and Linux operating systems. It has good scalability, reliability, and manageability ), thank you for providing us with such powerful and practical open-source software.

LVS features:

1. Strong anti-load ability, working on Layer 4 of the network for distribution only, no traffic is generated, this feature also determines its strongest performance in the load balancing software;

2. Low configuration, which is a disadvantage and an advantage. Because there is no configuration item, there is no need for too many contacts, which greatly reduces the chance of human error;

3. Work is stable. We have a complete dual-host Hot Standby solution, such as LVS + keepalived and LVS + heartbeat. However, we use LVS/DR + keepalived most in project implementation;

4. No traffic. This ensures that the I/O performance of the balancer will not be affected by large traffic;

5. A wide range of applications, allowing Load Balancing for all applications;

6. The software itself does not support Regular Expression Processing and does not support static/dynamic separation. In fact, many websites have strong requirements in this regard, this is the advantage of nginx/haproxy + keepalived.

7. If there are a large number of website applications, implementing LVS/DR + keepalived is complicated. In particular, if there are machines for Windows server applications, if the implementation, configuration, and maintenance process are complicated, nginx/haproxy + keepalived is much simpler.


Nginx features:

1. Working on Layer 7 of the network, you can implement some shunting policies for HTTP applications. For example, for domain names and directory structures, its regular rules are more powerful and flexible than haproxy, this is one of the reasons many friends like it;

2. nginx has a very small dependence on the network. Theoretically, it can be pinged to implement the load function, which is also its advantage;

3. nginx installation and configuration are relatively simple and easy to test;

4. It can also handle high load pressure and stability, and generally support tens of thousands of concurrent requests;

5. nginx can detect internal server faults through ports, such as processing status codes returned by webpages Based on the server, timeout, and so on, and resubmit the returned error requests to another node, however, the disadvantage is that URL detection is not supported;

6. nginx only supports HTTP and email, which is much smaller in the scope of application, which is weak;

7. nginx is not only an excellent Load balancer/reverse proxy software, but also a powerful Web application server. Lnmp is also a very popular Web architecture. It has a lot to fight against the most popular lamp architecture in the past, and has a good effect in a high-traffic environment.

8. nginx is now becoming more and more mature as the Web reverse acceleration cache. Many friends have already put it into production in the production environment, and the results are good, with a faster speed than the traditional squid server, if you are interested, you can consider using it as the reverse proxy accelerator.


Haproxy features:

1. haproxy supports Virtual Hosts. A friend once said that this does not support virtual hosts. I would like to correct it here.

2. It can supplement some shortcomings of nginx, such as session persistence and cookie guidance.

3. It is helpful to detect problems on the backend servers using URLs.

4. Like LVS, haproxy is only a Server Load balancer software. In terms of efficiency, haproxy provides better load balancing speed than nginx, it is superior to nginx in concurrent processing.

5. haproxy can perform load balancing on MySQL reads, and detect and load balancing the backend MySQL nodes. However, when the number of backend MySQL slaves exceeds 10, the performance is inferior to LVS, so I recommend LVS + keepalived to you.

6. More and more haproxy algorithms are available, including the following eight algorithms:

① Roundrobin indicates simple round robin. This is basically what Server Load balancer has;

② Static-RR, indicating that according to the weight, we recommend that you pay attention to it;

③ Leastconn, which indicates that the minimum number of connectors is handled first. We recommend that you pay attention to it;

④ Source indicates the request source IP address. This is similar to the ip_hash mechanism of nginx. We use it as a solution to the session problem. We recommend that you pay attention to it;

⑤ Ri, indicating the URI based on the request;

⑥ Rl_param indicates the request URL parameter 'balance url_param' requires an URL parameter name;

7. HDR (name) indicates locking each HTTP request based on the HTTP request header;

Extends RDP-cookie (name) indicates that each TCP request is locked and hashed Based on the cookie (name.

This article from the "fuqin liquor" blog, please be sure to keep this source http://andrewyu.blog.51cto.com/1604432/697466

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.