Understanding and summarization of load balancing of four layers and seven layers

Source: Internet
Author: User

the difference between one or four layer and seven layer load balancing

Seven-tier load balancing is based on HTTP protocol, and is suitable for load balancing of Web server. (Nginx)

The four-layer load balancing is based on TCP protocol packet and can do any load balancing of software based on TCP/IP protocol. (Haproxy, LVS)

The main difference is that the use of the message at the level is different, each has its own benefits.

The benefits of the seven-tier application load are to make the entire network more "intelligent". For example, to access the user traffic of a Web site, you can forward requests to a picture class to a specific image server and use caching techniques in a seven-tier way, and you can forward requests for text classes to specific text servers and use compression techniques. Of course, this is only a seven-tier application of a small case, from the technical principle, this way can be the client's request and the response of the server in any sense of modification, greatly enhance the application system in the network layer flexibility. Many features that are deployed in the background, such as Nginx or Apache, can be moved forward to load-balancing devices, such as header overrides in customer requests, keyword filtering in server responses, or content insertion.


The four-layer load balancing is more flexible and can be used as a load balancer for many kinds of software.


second, load balance of the data flow through the load balancer, how to solve the load balancer bottleneck problem

1. By modifying the source address and destination address of the TCP message, the data returned from the Web server is returned directly to the client, which is not possible with seven-tier load balancing because TCP three handshake is established between the client and the load balancing server, and the HTTP protocol is based on the TCP protocol, Establish a good TCP link before sending HTTP message, received HTTP message that load balancer and the client has established a TCP connection, and the Web server and client TCP links are not established, how to return data to the client.


The above method will have the problem: all cluster hosts are intranet IP, can not contact with the outside world.


Solution 1:

If you can buy so many extranet IP addresses to use and then load balance to the real Web server when TCP links are built, let the client and server establish a TCP link


Solution 2:

Quote: All problems with computers can be solved by creating a layer of virtual layers.

You can virtualize all server host IP to a load-balanced server IP, so that all hosts of the server cluster can access the external network, because the IP address (network layer, layer three) are the same, so only through the second layer to identify data flow, modify the Data link layer (second level) destination host MAC address, Send the request to the Web server before the TCP connection is actually established, and the Web server can return data directly to the client because it can be networked


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.