Comparison and analysis of Nginx load balancing and LVS load balancing

Source: Internet
Author: User
Tags hosting node server nginx load balancing

LVS and Nginx can be used as a multi-machine load scheme, each with excellent shortage, in the production environment need to analyze the actual situation and use.

First of all remind, do technology must not conform to, I cloud is you cloud, at the same time also not too tend to conservative, too believe the old has the way and wait others to help you to do mat is tested. It is a good habit to delve into all the good things that are immediately heard and to improve your knowledge and level of technology.

Here's a look at both of them:

First, the advantages of LVS:

1, strong anti-load ability, because the LVS work mode logic is very simple, and work in the Network 4 layer only to do the request for distribution, no traffic, so in the efficiency of the basic need not too much consideration. In my hand, the LVS, just once the problem: in the concurrency of the highest period of time the equalizer drops packet phenomenon, according to the analysis of network problems, that is, Nic or linux2.4 core load capacity has reached the upper limit, memory and CPU basic no consumption.

2, low-profile, which is usually a major disadvantage, but also a big advantage, because there is not too many configurable options, so in addition to increase or decrease the server, do not need to touch it frequently, greatly reducing the chance of human error.

3, the work is stable, because of its own resistance to load capacity is very strong, so the stability is also natural, and a variety of LVS have a complete dual-machine hot-standby scheme, so a little do not worry about the equalizer itself will be what problems, node failure, LVS will automatically distinguish, so the overall system is very stable.

4, no flow, the above has been mentioned. LVS simply distributes the request, and the traffic does not go out of it itself, so it can be used to do some line diversion. Without traffic, the IO performance of the Equalizer will not be affected by large traffic.

5, basically can support all applications, because LVS work in the 4 layer, so it can load balance almost all applications, including HTTP, database, chat room and so on.

Another: LVS is not fully able to identify node failure, for example, in the WLC allocation mode, there is a node in the cluster is not configured VIP, will make the whole cluster can not be used, then use WRR allocation method will lose a machine. The problem is still being tested further. Therefore, the use of LVS also have to be more careful to be wonderful.

Second, the results of the comparison between Nginx and LVs

1, Nginx work in the Network 7 layer, so it can be targeted at the HTTP application itself to do the shunt strategy, for example, for the domain name, directory structure, in contrast, LVS does not have such a function, so the nginx alone can use the occasion far more than LVS But Nginx useful these functions make its adjustable degree is higher than LVS, so often to touch touch, from the 2nd advantage of LVs See, touch more, the probability of human problems will be big.

2, Nginx dependence on the network is small, theoretically as long as the ping, the Web Access is normal, nginx can be connected, nginx can also distinguish between inside and outside the network, if it is also a node with internal and external network, the equivalent of a single machine has a backup line; LVs is more dependent on the network environment, At present, the server in the same network segment and LVS using direct mode shunt, the effect is more guaranteed. In addition, the LVS need to apply to the custodian at least one more IP to do the visual IP, it seems that it is not possible to use their own IP to do VIP. To do a good job of the LVS administrator, do have to follow up learning a lot about network communication knowledge, it is no longer an HTTP so simple.

3, Nginx installation and configuration is relatively simple, testing is also very convenient, because it is basically able to print out the error log. LVS installation and configuration, testing will take a long time, because, as mentioned above, LVS depends on the network is relatively large, many times can not be configured to succeed because of network problems rather than configuration problems, out of the problem to solve also the corresponding will be more troublesome.

4, Nginx can also withstand a very high load and stability, but the load and stability of the LVS there are several levels: Nginx processing all traffic is limited to the machine IO and configuration, its own bugs are still unavoidable; Nginx does not have ready-made dual-machine hot standby scheme, so running on a single computer or a large risk, Everything on a single machine is hard to say.

5, Nginx can detect the internal failure of the server, such as the server to handle the return of the page status code, timeout and so on, and will return the wrong request resubmitted to another node. At present, LDIRECTD in LVS can also support monitoring the internal conditions of the server, but the principle of LVS makes it impossible to re-send requests. Resend the request this, for example, the user is uploading a file, and processing the upload node just in the upload process failure, Nginx will upload to another server to re-processing, and LVS directly broken off, if it is to upload a large file or very important files, users may be annoyed.

6, Nginx to the request of asynchronous processing can help the node server to reduce the load, if using Apache Direct service, then there are a lot of narrow-band link when the Apache server will occupy a lot of memory and can not be released, using more than one nginx to do Apache agent, These narrow-band links will be blocked by Nginx, Apache will not accumulate too many requests, which reduces the amount of memory consumption. This use squid also has the same effect, even if the squid itself is configured to not cache, the Apache still has a lot of help. LVS does not have these features and cannot be compared.

7, Nginx can support HTTP and email (the function of email is estimated to be less used), the application supported by LVS will be more than Nginx.

In use, the general front-end strategy should be the LVS, that is, the DNS point should be the LVS equalizer, the advantages of LVS make it very suitable for this task.

Important IP address, preferably by the LVS hosting, such as the database IP, WebService server IP and so on, these IP addresses over time, the use of polygons will become larger, if the replacement of IP will follow. So it is most prudent to give these important IPs to the LVS hosting, the only disadvantage is that the number of VIPs will be more.

Nginx can be used as the LVS node machine, one can use Nginx function, the second is the performance of Nginx can be used. Of course, this level can also directly use the function of Squid,squid is weaker than Nginx, performance is also inferior to nginx.

Nginx can also be used as a middle-tier agent, this level nginx basically no opponent, the only one can shake Nginx only lighttpd, but lighttpd at present has not been able to do nginx full function, configuration is not so clear and easy to read. In addition, the middle-level proxy IP is also important, so the middle-level agent also has a VIP and LVs is the most perfect solution.

Nginx can also be used as a static Web server, but beyond the scope of this discussion, simply mention.

Specific application also have to be specific analysis, if it is relatively small site (pv<1000 million), with Nginx can be completely, if the machine is also a lot, you can use DNS polling, LVS, the cost of the machine is more; large web sites or important services, machines do not worry about the time, You should consider using LVs a lot.

Comparison and analysis of Nginx load balancing and LVS load balancing

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.