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, strong anti-load capacity, is working in the Network 4 layer only for distribution, no flow generation, 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 reduce the chance of human error, 3, the work is stable, self has a full foot bath powder of the two-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, Ensure that the performance of the Equalizer IO will not be affected by large flow, 5, the application of a wide range of applications can be load balanced; 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 nginx/ The advantages of 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 HTTP applications to do some diversion strategy, such as for the domain name, directory structure, its regular rules than haproxy more powerful and flexible, which is also a lot of friends like it one of the reasons; 2, nginx dependence on the network is very small, Theoretically can ping pass can carry on the load function, this is also its superiority; 3, Nginx installation and configuration is relatively simple, testing is 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 be detected through the port of the foot powder server internal failure, such as according to the server processing page return status code, timeout, etc., and will return the wrong request 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 foot bath powder 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 be added to some of the shortcomings of Nginx such as the session to maintain, the guidance of the cookie work 3, support URL detection backend server problem detection will be very good help. 4, it is just like the LVS, itself is only a foot bath powder 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 read to MySQL load balance of foot bath , 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 more and more, specifically the following 8 kinds: ①roundrobin, the simple polling, this does not say, this is the load Balancer basic have, ②STATIC-RR, said according to the weight, recommended attention; ③leastconn, Indicates that the least connection is processed first, it is recommended to pay attention to, ④source, according to the request source IP, this is similar to Nginx's ip_hash mechanism, we use it as a method to solve the session problem, it is recommended to pay attention to, ⑤ri, indicating that according to the uri;⑥rl_param of the request, Represents the URL parameter ' balance Url_param ' requires an URL parameter Name;⑦hdr (name) according to the request, which indicates that each HTTP request is locked according to the HTTP request header; ⑧rdp-cookie (name), Indicates that each TCP request is locked and hashed according to the cookie (name).
Comparison of features between LVS and common Web server Software