Analysis of advantages and disadvantages of LVS Nginx Haproxy

Source: Internet
Author: User
Tags port number haproxy advantage

It is relatively simple to build a load-balanced high availability environment, mainly to understand the principle. This article describes the advantages and disadvantages of three load balancers, so as to be in the actual production applications, according to the requirements of choice.
At present, the online environment in the application of more load Balancer hardware F5 big-ip, software has Lvs,nginx and haproxy, high availability of software heartbeat, keepalived, mature structure lvs+keepalived, nginx+ Keepalived, haproxy+keepalived and Drbd+heartbeat.
The advantages and disadvantages of the three load balancers are described below:
The advantages of LVS:
1, strong load resistance, work on the 4th floor for distribution only, no flow of production, this feature also determines that it in the load-balancing software performance of the strongest; no flow, while ensuring that the performance of the Equalizer IO will not be affected by large flow;
2, the work is stable, oneself has the complete dual machine hot standby plan, like lvs+keepalived and lvs+heartbeat;
3, the application of a wide range of applications can be done to load balance;
4, the configuration is relatively low, this is a disadvantage is also an advantage, because there is not too much configuration of things, so do not need too much contact, greatly reduce the probability of human error;
The disadvantages of LVS:
1, the software itself does not support regular processing, can not do static and dynamic separation, which highlights the advantages of nginx/haproxy+keepalived.
2, if the site application is relatively large, lvs/dr+keepalived is more complex, especially after Windows Server application of the machine, implementation and configuration and maintenance process is relatively troublesome, relatively, nginx/haproxy+ The keepalived is much simpler.
#############################################################
1. Lvs/dr How to handle the request message, will modify the IP packet content?
1.1 VS/DR itself will not care about the information above the IP layer, even if the port number is the TCP/IP protocol stack to determine whether the correct, vs/dr itself mainly to do so several things:
1 to receive the client's request, according to your set of load balancing algorithm to select a Realserver IP;
2 to select the IP corresponding MAC address as the target Mac, and then again the IP packet encapsulated into frames forwarded to the RS;
3 Record the connection information in the hash table.
VS/DR does a lot of things, and it's very simple, so it's very efficient, no less than the hardware load balancing device.
The approximate flow of data packets and data frames is such that:client–> vs–> rs–> client
1.2 The previous answer has been answered, VS/DR will not modify the contents of the IP packet.
2. Why should realserver configure the VIP on the Lo interface? Is it OK to configure the VIP on the exit card?
2.1 If you want RS to be able to handle IP packets with the destination address as VIP, you must first allow RS to receive this package.
Configuring the VIP on Lo can complete the receive package and return the result to the client.
2.2 The answer is not to the VIP set in the export card, otherwise will respond to the client ARP request, resulting in Client/gateway arp table disorder, so that the entire load balance can not work properly.
3. Why should realserver suppress ARP frames?
This issue has been explained in the previous question, which is further elaborated in conjunction with the implementation order. We will make the following adjustments when we implement the deployment in detail:
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
I'm sure a lot of people will not understand what they are doing, just know that there must be. I am not going to come up with a detailed discussion here, just to make a few notes, just as a supplement.
3.1
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
These two are not available because ARP has no meaning to the logical interface.
3.2 If your RS external network interface is eth0, then
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
Actually, the real implementation is:
echo "1" >/proc/sys/net/ipv4/conf/eth0/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/eth0/arp_announce
So my personal suggestion is to add the top two to your script, because if the two default values in the system are not 0, there may be problems.
4. LVS/DR Load Balancer (director) and RS Why should be in the same network segment?
From the first question, you should understand how VS/DR forwarded the request to RS, right? It is implemented at the data link layer, so the director must be in the same network segment as Rs.
5. Why director on the LO interface in addition to the VIP in addition to the eth0 with an IP (ie dip)?
5.1 If the use of keepalived and other tools to do ha or load Balance, you need to use a dip in health screening.
5.2 ha or Load balance without a health screening mechanism has no practical significance.
6. Does lvs/dr Ip_forward need to be opened?
No need. Because director and Realserver are the same network segment, you do not need to turn on forwarding.
7. Director's VIP netmask must be 255.255.255.255?
In Lvs/dr, director's VIP netmask need not be set to 255.255.255.255.
Route add-host $VIP Dev eth0:0
Director's VIP is to be like the normal IP address as an external notice, do not make so special.
8. How do I lvs/dr tcp three times?
#####################################################################
Advantages of Nginx:
1, working in the OSI layer 7th, you can do some streaming strategy for HTTP applications. For example, for domain names, directory structure. It is more powerful and flexible than haproxy;
2, Nginx dependence on the network is very small, theoretically can ping the load function, this is its advantage;
3, Nginx installation and configuration is relatively simple, testing more convenient;
4, can bear high load pressure and stability, generally can support more than tens of thousands of times the concurrent volume;
5, Nginx can detect the server's internal faults through the port, such as the status code returned by the server processing page, timeout, and so on, and will return the wrong request resubmitted to another node;
6, 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 environment, and the lamp environment, nginx in dealing with static pages, especially against high concurrency relative to Apache advantages;
7, Nginx now as a web reverse acceleration cache more and more mature, faster than the traditional squid server, the need for friends can consider using it as a reverse agent accelerator;
Disadvantages of Nginx:

1, Nginx does not support the URL to detect.
2, Nginx can only support HTTP and email, this is its weakness.
3, the nginx of the session to maintain the ability to guide the cookie is relatively deficient.
Advantages of Haproxy:

1, Haproxy is to support the virtual host, you can work in 4, 7 layer (support multiple network segment);
2, can supplement nginx some shortcomings such as the maintenance of the session, cookies, such as the guidance of work;
3, support the URL detection backend server;
4, it is just like the LVS, itself is only a load-balancing software, simply from the efficiency of haproxy more than nginx have a better load balancing speed, in the concurrent processing is also superior to nginx;
5, Haproxy can be read to the MySQL load balance, the back-end of the MySQL node detection and load balancing, but in the back-end of the MySQL slaves number of more than 10 when the performance is less than LVS;
6, the Haproxy algorithm is more, achieves 8 kinds;

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.