Load balancing implementation-Hardware balancer vs. software distribution connections

Source: Internet
Author: User
Tags http request mysql database haproxy

from:http://yuhongchun.blog.51cto.com/1604432/697466

Now the trend of Web site development on the use of Network Load balancing with the increase of site size according to different stages to use different technologies:
One is the hardware to carry out, the common hardware has more expensive NetScaler, F5, Radware and array and other commercial load balancer, it is the advantage of a professional maintenance team to maintain these services, the disadvantage is that the cost is too large, So for the smaller network services for the time being no need to use, and another is similar to Lvs/haproxy, Nginx Linux-based open source free load balancing software strategy, these are implemented through the software level, so the cost is very low, So I also recommend that you use the second scenario to implement your own site load balancing requirements.

Recently friend Liu Xin (Purple Rain Snow) project successfully on-line, PV reached billion/day of traffic, the most front-end with the Haproxy+keepalived dual-machine load balancer/reverse proxy, the entire website is very stable ; This makes me more determined to talk to the old boy before the architecture of the reasonable design of the Web site: nginx/haproxy+keepalived as the Web front-end load balancer, the back-end of the MySQL database architecture using a master multi-slave, read-write separation method, using lvs+ Keepalived the way.

Here I also have a little to tell you: Many friends worry about software-level load balancing under high traffic impact stability, the fact is that we have successfully launched many sites found that their stability is very good, the possibility of downtime is very small, so I now do the project, The high availability of service levels is largely not considered. I believe you have a very deep understanding of these software-level load balancing software, the following I have their characteristics and the application of the occasion to explain separately.

LVS: Using cluster technology and Linux operating system to achieve a high-performance, highly available server, it has good scalability (Scalability), Reliability (reliability) and manageability (manageability), Thank Dr. Zhangwensong for providing us with such powerful and practical open source software.
LVS is characterized by:
1, anti-load capacity, is the work in the Network 4 layer only for distribution, no traffic generated, this feature also determines its performance in the Load Balancer software is the strongest;
2, the configuration is relatively low, this is a disadvantage is also an advantage, because there is not much to configure things, so do not need too much contact, greatly reducing the chance of human error;
3, the work is stable, self has a complete dual machine hot-standby program, such as Lvs+keepalived and lvs+heartbeat, but we in the project implementation of the most used or lvs/dr+keepalived;
4, no flow, to ensure that the performance of the Equalizer IO will not receive the impact of large traffic;
5, a wide range of applications, can be load-balanced for all applications;
6, the software itself does not support the regular processing, can not do static and dynamic separation, this is more regrettable; in fact, many sites in this area have a strong demand, this is the advantage of nginx/haproxy+keepalived.
7, if the site is a relatively large application, the implementation of lvs/dr+keepalived up is more complicated, especially after the Windows Server application of the machine, if the implementation and configuration and maintenance process is more complex, relatively, nginx/haproxy+ Keepalived is a lot easier.

The features of Nginx are:
1, work in the network on the 7 layer, can be targeted for the HTTP application to do some diversion strategy, such as for the domain name, directory structure, its regular rules than haproxy more powerful and flexible, which is a lot of friends like it one of the reasons;
2, Nginx dependence on the network is very small, in theory can ping through the load function, this is its advantage;
3, Nginx installation and configuration is relatively simple, testing more convenient;
4, can also bear high load pressure and stability, generally can support more than tens of thousands of times the concurrency;
5, Nginx can detect the server internal fault through the port, for example, according to the server processing the status code returned by the Web page, time-out and so on, and will return the wrong request resubmitted to another node, but the disadvantage is that the URL is not supported to detect;
6, Nginx can only support HTTP and email, so much smaller in the scope of application, this it's weak;
7, Nginx is not only a good load balancer/reverse proxy software, it is also a powerful Web application server. LNMP is now also a very popular web architecture, with a strong resistance to the previous most popular lamp architecture chambers, and has a good effect in high-traffic environments.
8, Nginx now as the Web reverse acceleration cache more and more mature, many friends have been put into production environment, and reflect the effect is good, faster than the traditional squid server, interested friends can consider using it as a reverse proxy accelerator.

Haproxy is characterized by:
1, Haproxy is to support the virtual host, a friend said before that this does not support virtual hosting, I hereby correct.
2, can add some of the shortcomings of Nginx such as the session of the maintenance, cookie guidance and other work
3, support the URL detection backend server problem detection will be very good to help.
4, it is just like the LVS, itself is only a load balancer software, simply from the efficiency of the haproxy more than Nginx has a better load balancing speed, in concurrent processing is better than nginx.
5, Haproxy can load balance MySQL read, the back end of the MySQL node detection and load balancing, but in the back end of the number of MySQL slaves more than 10 units performance than LVS, so I recommend to you lvs+keepalived.
6, Haproxy's algorithm is now also more and more, specifically the following 8 kinds:
①roundrobin, said the simple polling, this is not much to say, this is the load balancer basically have;
②STATIC-RR, said according to the weight, suggest concern;
③leastconn, indicating that the minimum number of connections to deal with, suggest concern;
④source, according to the request source IP, this is similar to Nginx's ip_hash mechanism, we use it as a way to solve the session problem, it is recommended to pay attention to;
⑤ri, which represents the URI according to the request;
⑥rl_param, which represents the URL parameter according to the request ' balance Url_param ' requires an URL parameter name;
⑦HDR (name), which indicates that each HTTP request is locked according to the HTTP request header;
⑧rdp-cookie (name), which indicates that each TCP request is locked and hashed according to the cookie (name).

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.