1 thought on “nginx lvs haproxy which one is used more”

  1. 1. The advantage of LVS:

    1. Strong resistance to the lane, because the logic of the LVS working method is very simple, and the work on the 4th floor of the network is only for distribution, there is no traffic, so efficiency is efficient, so it is efficient at efficiency. There is basically no need to think too much.在我手里的lvs,仅仅出过一次问题:在并发最高的一小段时间内均衡器出现丢包现象,据分析为网络问题,即网卡或linux2.4内核的承载能力已到上限,内存和The CPU is basically not consumed.

    2, low configuration, this is usually a major disadvantage, but it is also a major advantage, because there are not many configuration options, so except to increase or decrease the server, you do not need to touch it often to touch it often It greatly reduces the chance of artificial errors.

    3. The work is stable. Because of its strong resistance to load, high stability is also logical. In addition, various LVS have a complete dual -machine thermal preparation solution, so you don’t have to worry about the balancer itself itself will itself. What problems are? If the node fails, LVS will automatically judge, so the system as a whole is very stable.

    4, no traffic, it has been mentioned above. LVS only distributes requests, and the traffic does not go out from it, so it can be used to do some line diversion. At the same time, the IO performance of the equalizer will not be affected by large flow.

    5. Basically, it can support all applications. Because LVS works on the 4th floor, it can make a load balancing almost all applications, including HTTP, database, chat room, and so on.

    It: LVS can not completely judge the node failure. For example, in the WLC distribution method, there is a node in the cluster that is not configured with VIP, which will make the entire cluster unavailable. Will lose a machine. This problem is currently under testing. Therefore, it is better to use LVS.

    . The results of the comparison of Nginx and LVS

    1, nginx work on the 7th floor of the network, so it can be used for the HTTP application itself, such as the domain name, the domain name, the domain name, the domain name, The directory structure, etc. In contrast, LVS does not have this function, so Nginx alone is far more available than LVS; but these functions of Nginx make it more adjustable than LVS, so Frequent touch and touch. From the advantages of Article 2 of LVS, if you touch more, the chance of artificial problems will be high.

    2, Nginx's dependence on the network is small. In theory, as long as ping is connected, the webpage access is normal, Nginx can be connected. Nginx can also distinguish the internal and external networks at the same time. Nodes are equivalent to a single -machine backup line; LVS depends more on the network environment. At present, the server is in the same network segment and LVS is diverted by Direct, and the effect is more guaranteed. In addition, LVS needs to apply to the custodian at least one more IP to make a Visual IP. It seems that you cannot use your own IP to make VIP. To do a good job of LVS administrators, it is no longer as simple as a HTTP.

    3, nginx installation and configuration are relatively simple, and it is also very convenient to test, because it can basically print the misunderstanding with logs. The installation and configuration and test of LVS take a long time, because the same as above, LVS relies heavily on the network. Many times the configuration cannot be successful because of network problems and not configuration problems. It will be much more troublesome.

    4, nginx, can also withstand high load and stable, but there are several levels of load degree and stability poor LVS: nginx processing all traffic is limited by the machine IO and configuration; the bug of its own BUG It is still unavoidable; Nginx does not have a ready -made dual -machine heat preparation solution, so running on the single machine is still greater, and it is difficult to say on the stand -alone things.

    5, nginx can detect the failure inside the server, such as the status code, timeout, etc. according to the server processing webpage, etc., and will submit the returned wrong request to another node. At present, LDIRECTD in LVS can also support the surveillance of the internal situation of the server, but the principle of LVS makes it unable to re -issue the request. Re -issuing requests, for example, the user is uploading a file, and the handling of the uploaded node is just a failure during the uploading process. Nginx will cut the upload to another server to handle it, and the LVS will be broken directly. If uploading a large file or very important file, the user may be annoyed because of this.

    6, Nginx's asynchronous treatment of the request can help node servers to reduce the load. If you use Apache directly to the external service, the Apache server will occupy a large amount of memory when there are many narrow band links. If Nginx is an Apache agent, these narrow belt links will be blocked by nginx, and there will be no excessive requests on Apache, which reduces a considerable amount of memory occupation. This uses Squid also has the same effect. Even if the Squid itself is configured as not cache, it is still very helpful for Apache. LVS does not have these functions, and it cannot be compared.

    7, nginx can support HTTP and Email (Email's functional estimation is relatively small), and the application supported by LVS will be more than nginx.

    In terms of use, the strategy adopted at the forefront should be LVS, that is, the direction of the DNS should be the LVS balancer. The advantages of LVS make it very suitable for this task.

    The important IP address, it is best to be handed over to the LVS custody, such as the IP of the database, the IP of the server, etc. These IP addresses will be larger and larger over time, and the use surface will become larger and larger. The failure will follow. Therefore, it is the most secure to hand over these important IPs to LVS hosting. The only disadvantage of this is that the number of VIPs required will be more.

    NGINX can be used as a LVS node machine. One is to use the function of Nginx, and the other is that the performance of Nginx can be used. Of course, this level can also be used directly with Squid. The function of Squid is much weaker than Nginx, and the performance is inferior to Nginx.

    NGINX can also be used as a middle agent. At this level, nginx is basically no opponent. The only one that can shake Nginx is LightTPD. So clear and easy to read. In addition, the IP of the middle agent is also important, so the middle agent also owns a VIP and LVS is the most perfect solution.

    NGINX can also be used as a web static server, but it exceeds the scope of this article. Simply mention it.

    The specific application must be analyzed. If it is a relatively small website (daily PV u003C10 million), it is okay to use Nginx. There are more machines that are consumed; large websites or important services, when the machine is not worried, consider using LVS. rn********************************************** *************************************************** *******************
    NGINX's advantages:
    The performance is good, and it can load more than 10,000 concurrency.
    has many functions. In addition to the load balancing, it can also be used as a web server, and the flow distribution can be achieved through the GEO module.
    The community is active, and many third -party patch and modules
    Id GZIP Proxy
    Disadvantages:

    The effect on the health check function of the back end is not good. And only support the detection through the port, and does not support the detection through the URL.
    NGINX's support for Big Request Header is not very good. If the client_header_buffer_size is set relatively small, it will return the 400Bad Request page. The advantages of
    haproxy:
    This advantages can supplement the shortcomings of Nginx. Support session maintenance, and support the state of the back -end server by obtaining the specified URL.
    The load balancing supports TCP mode. For example, a load balancing from the server cluster and mail server of MySQL.
    Disadvantages:
    does not support virtual hosting (this is stupid)
    The performance monitoring template without NAGIOS and CACTI
    LVS:
    Network throughput and connection load capacity.
    LVS's DR mode supports load balancing through the wide area network. No other load balancing software is currently not available.
    Disadvantages:
    relatively heavy type. In addition, the community is not as active as nginx. rn********************************************** *************************************************************************************************************************** r n
    Common load balancing is mainly divided into two types: one is performed by hardware. Common hardware has more expensive NetScaler, F5, Radware, and Array and other commercial load balangers. Based on the linux open source load balancing strategy,
    The commercial load balancing in the commercial load balancing is higher than the F5 efficiency in terms of effect. For the load balanner, because the commercial load balancing can be built on the four -to seventh floor protocol, the applicable surface is wider, so it is irreplaceable. His advantage is that there is a professional maintenance team to maintain these services to maintain these services. The disadvantage is that it costs too much, so it is not necessary for the smaller network services for the time being.
    . Another way of load balancing is through software: more common ones are LVS, Nginx, Haproxy, etc. Among them, LVS is built on the four -layer protocol, while Nginx and Haproxy are built on the seven -layer protocols In the following, the following introduces
    LVS: Use cluster technology and Linux operating system to achieve a high -performance, high -available server, which has good ejaculation (), reliability (), and management (). The characteristics of
    LVS are:
    1, strong load resistance, is only for distribution on the 4th floor of the network, without traffic generation;
    2, the configuration is relatively low, this is a one The disadvantage is also an advantage, because there is no more configuration, so it does not require too much contact, which greatly reduces the chance of artificial errors;
    3, the work is stable, and it has a complete dual -machine thermal preparation solution;
    4, no traffic, ensuring that the performance of the equalizer IO will not receive the impact of large flow;
    5, the application range is relatively wide, you can make load balancing all applications;
    6, LVS need to be more to IDC more Applying for a IP to make a Visual IP, so it requires a certain network knowledge, so the requirements for operators are relatively high. The characteristics of
    NGINX are:
    1. Work on the 7th floor of the network, you can make some diversion strategies for HTTP applications, such as the domain name and directory structure;
    2, nginx's dependence on the network Small;
    3, nginx installation and configuration are relatively simple, and it is more convenient to test;
    4, can also bear high load pressure and stable, generally supports more than 10,000 concurrency;
    5, nginxx You can detect the internal fault inside the server through the port, such as processing the status code, overtime, etc. according to the server processing the webpage, and will submit the return wrong request to another node, but the disadvantage is that it does not support URL to detect;
    6, Nginx's asynchronous processing of requests can help node servers to reduce loads;
    7, nginx can support HTTP and Email, so that it is much smaller in the scope of applicable; The support of the Request Header is not very good. In addition, only Round-Robin and IP-Hash load balancing algorithm is the default. The characteristics of
    haproxy are:
    1, haproxy is working on the 7th floor of the network.
    2, some disadvantages that can supplement Nginx, such as the maintenance of session, work such as cookies, guidance
    3, detection of server problems that support URL detection back -end server problems will help.
    4, more load balancing strategies, such as: dynamic weighted Round Robin, weighted source address, weighted Source Hash, weighted URL hash and weighted parameter hash (Weight Parameter Hash) has achieved it
    5. In terms of efficiency, Haproxy will have better load balancing speed than Nginx.
    6, Haproxy can carry a load balancing of MySQL, detect and load balancing on the back -end DB node. rn********************************************** ************************************************* R n
    The use of web development trends The use of network load balancing is to use different technologies with different stages:
    It -stage: Using Nginx or HAPROXY to perform single -point points for single points The load balancing. At this stage, the server scale has just been separated from the mode of single server and single database. It requires a certain load balancing, but it still has a smaller scale without a professional maintenance team for maintenance, and there is no need for large -scale website deployment. This is the first choice to use Nginx or HAPROXY. At this time, these things are fast and easy to configure. You can use the HTTP protocol on the seventh floor. At this time is the first choice
    : As the network service further expands, the Nginx of the single point is no longer satisfied. At this time, using LVS or commercial F5 is the primary choice. At this time The nodes are used. The specific LVS or F5 is selected according to the size of the company, talents and funding capabilities, and do not talk about it here, but in general, related talents can not keep up with the business improvement, so buy commercial business at this stage, so buy commercial business, so buy business The load balancing has become a must -have.
    The third stage: At this time, network services have become mainstream products. At this time, as the company's popularity is further expanded, the ability and quantity of related talents will also increase. In terms of reducing costs, open source LVS has become the first choice. At this time, LVS will become the mainstream.
    The ideal state of the final formation is: F5/LVS u003C--> Haproxy u003C--> Squid/Varnish u003C--> AppServer.

Leave a Comment