当前位置:网站首页>LVS four layer load balancing cluster (4) main methods of load balancing

LVS four layer load balancing cluster (4) main methods of load balancing

2022-06-13 03:39:00 51CTO

http Redirect

principle

Download websites more often , In fact, it is also a kind of load balancing , Work in the business code of the application layer According to the user's http Request to compute a real web Server address , And put the web Server address write http The redirect response is returned to the client browser , Revisited by browser

LVS Four layer load balancing cluster (4) The main way of load balancing _ Load balancing

Advantages and disadvantages

advantage : Relatively simple

shortcoming : The client browser needs to request the server many times to complete an access , Poor performance .

       http The processing capacity of the redirection server itself may become a bottleneck .

        Use http302 Response redirection , It is possible for search engines to judge that SEO cheat , Reduce search rankings .


DNS Load balancing

principle

DNS The payload provides domain names to IP Analytical process , In fact, this is the time when we check Baidu's domain name resolution DNS The server also acts as a load balancer , The intelligence provided by many domain name operators dns And multiline analysis are all based on DNS Load balancing technology , Open source BIND It can provide powerful technologies such as telecom Unicom multi line analysis .

stay DNS Multiple domain names are configured on the server IP The record of . For example, a domain name www.baidu.com Corresponding to a group of web The server IP Address , Domain name resolution through DNS The server's algorithm allocates a domain name request to an appropriate real server .

LVS Four layer load balancing cluster (4) The main way of load balancing _ Load balancing _02LVS Four layer load balancing cluster (4) The main way of load balancing _ Load balancing _03

Advantages and disadvantages

advantage :

It's up to DNS, It saves the trouble of website management and maintenance of load balancing server , At the same time, many DNS It also supports domain name resolution based on geographical location , Resolve the domain name to the server address closest to the user's geography , Speed up access , improve performance .

shortcoming :

current DNS Parsing is multistage parsing , Each level DNS It's possible to cache records A, When a server is offline , The server corresponds to DNS Record A There may still be , Causes the user assigned to the server to fail to access .

       DNS The control of load balancing is in the hands of domain name service providers , The website may not be able to make too much improvement and management .

        The load cannot be distributed according to the processing capacity of the server .DNS Load balancing uses a simple polling algorithm , Can't tell the difference between servers , Cannot reflect the current running state of the server , So its load balancing effect is not very good .

        May cause additional network problems . In order to make Ben DNS Servers and others DNS The server interacts in a timely manner , Guarantee DNS The data is updated in time , Enable random assignment of addresses , Generally, we have to DNS The refresh time of is set smaller , But being too small will make DNS The increase in traffic causes additional network problems .


Reverse agent load balancing

principle :

The reverse proxy is in web On the server side , The reverse proxy server provides the function of load balancing , Manage a group at the same time web The server , It forwards the requested browser access to different web The server processes , The processing results are returned to the browser through the reverse server .

  for example : The address of the browser access request is the address of the reverse proxy server 114.100.80.10, The reverse proxy server received the request , After the load balancing algorithm, a real physical address is obtained 10.0.0.3, And send the request result to the real server , After the real server finishes processing, it returns to the requesting user through the reverse proxy server .

LVS Four layer load balancing cluster (4) The main way of load balancing _linux_04

Advantages and disadvantages

advantage :

Simple deployment , be in http Agreement level .

shortcoming :

After using the reverse proxy server ,web The server address cannot be directly exposed , therefore web The server doesn't need to use external IP Address , As a communication bridge, reverse proxy service needs to be configured with dual network cards 、 Two sets of external and internal IP Address .


IP Network layer load balancing

principle

At the network layer and transport layer (IP And port ) Load balancing by modifying the target address . The user access request arrives at the load balancing server , The load balancing server obtains network packets in the kernel process of the operating system , Get a real server address according to the algorithm , Then modify the target address requested by the user to the real server address , The data is returned to the load balancing server after processing , After receiving the response, the load balancing server modifies its address to the original user access address, and then returns the data . Similar to reverse server load balancing .

LVS Four layer load balancing cluster (4) The main way of load balancing _ Load balancing _05

Advantages and disadvantages

advantage : When responding to requests, it is faster than reverse server load balancing .

shortcoming : Unable to process more advanced requests


Data link layer load balancing

  principle

Modify at the data link layer Mac Address load balancing . Load balancing server IP And what it manages web Virtual of service cluster IP Agreement ; In the process of load balancing data distribution, the access address is not modified IP Address , It's modification Mac Address ; Through these two points, the normal access can be carried out without modifying the original address and target address of the data packet .

LVS Four layer load balancing cluster (4) The main way of load balancing _linux_06

Advantages and disadvantages

advantage :

No load balancing server is required IP Address translation .

Data response , No need to go through load balancing server .

shortcoming :

The network card bandwidth requirements of the load balancing server are high .


F5 Hardware load balancing

principle

F5 BIG-IP Provide 12 A flexible algorithm distributes all traffic evenly to each server , And facing users , Just a virtual server .

Physical examination .F5 BIG-IP You can confirm whether the application can return the corresponding data to the request . If F5 BIG-IP A service stop occurred on one of the following servers 、 Crash, etc ,F5 It will check and identify the server as down , Thus, the user's access request is not transmitted to the failed server . such , As long as the other servers work properly , The user's access will not be affected . Once the downtime is repaired ,F5 BIG-IP It will automatically verify that the application ensures the correct response to the customer's request and resume transmission to the server .

F5 BIG-IP It's dynamic Session Session hold function , The author is also used in the website F5 Will the user IP And Session adopt F5 Binding made , Make it Session bring into correspondence with .

F5 BIG-IP Of iRules The function can do HTTP Content filtering , According to different domain names 、URL, Send access requests to different servers .

Advantages and disadvantages

advantage : Good performance

shortcoming : The high cost , Configuration redundancy


Four layer load and seven layer load

The so-called four levels are based on IP+ Port load balancing , The main representatives are lvs.

Seven layer load is also called content exchange , Is based on URL Load balancing of application layer information , The main representatives are nginx.

LVS Four layer load balancing cluster (4) The main way of load balancing _ Load balancing _07


Load balancing & agent

Load balancing is also called proxy , It's a kind of agency .

Forward agency

Only used to proxy internal network pairs Internet Connection request for , The client must specify a proxy server , And send it directly to Web On the server http The request is sent to the proxy server , A forward proxy is a client proxy , It is a proxy method controlled and known by the user , If I cannot access fb, Then a foreign server is used as a springboard , Finally, the successful access is the forward proxy .

Reverse proxy

To accept as a proxy server Internet Connection request on , Then forward the request to the server on the internal network ; And return the results from the server to the Internet Clients requesting connections on , At this time, the proxy server is represented as a server , Reverse proxy refers to the server-side proxy , Behind large websites, there is not only one machine to provide services , For example, I visit Weibo , A reverse proxy server of Weibo parses me to a machine of the internal server , Then the machine provides me with microblog messages ( Of course, the actual situation is much more complicated than this ), These are invisible to the user , We will only feel that there is only one machine interacting with me .

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130332546484.html