In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
A brief introduction to four models of LVS and Ten scheduling algorithms LVS
LVS:Linux Virtual Server, load Scheduler, Kernel Integration, Zhang Wensong (nickname Zhengming)
How LVS works
VS forwards the scheduling of the request message to a certain RS according to its target IP, target protocol and port, and selects the RS according to the scheduling algorithm.
Technical terms for LVS cluster types
VS:Virtual Server virtual server
RS:Real Server (lvs) servers that actually provide services
IP of the CIP:Client IP client
VIP: the IP set by the Virtual serve IP LVS server for the clients of the Internet, which is a virtual IP
DIP: the IP set by the LVS server in the Director IP LAN
RIP: IP of Real server IP real server
LVS server, client access flowchart
LVS-NAT mode
It is essentially the DNAT of multi-destination IP, which can be forwarded by modifying the destination address and destination port in the request message to the RIP and PORT of a singled RS.
(1) RIP and DIP should be on the same IP network and private network address should be used. The gateway of RS should point to DIP.
(2) both request message and response message must be forwarded through Director, and Director is easy to become the bottleneck of the system.
(3) Port mapping is supported, and the target PORT of the request message can be modified
(4) VS must be a Linux system, and RS can be any OS system.
Implementation Logic of LVS-NAT
As shown in the figure above, the client accesses the VIP that the LVS is open to the public through routing. When the LVS receives the request message, it will intercept it and transmit the request message to one of the RS servers through its own DIP (DIP and RIP need to be on the same local area network and the same network segment). After the RS server receives the request message, it sends the response message to the client through the LVS server (equivalent to going back as it comes). In the process of user access, the LVS server actually translates the address of the VIP into the IP of the official server, so as to communicate with each other.
NAT mode IP packet scheduling process
Working schematic diagram inside NAT mode
The reason why the LVS server can transfer the data packets sent to itself to other hosts is that LVS lurks in the hook function INPUT. Once it is found that the data packets accessed by users are sent to INPUT,LVS after passing through PREROUTING, they will be intercepted, the target address will be changed to the address of the real server, and then sent to the POSTROUTING, so as to send it to the real server to achieve the function of scheduling and forwarding.
Advantages and disadvantages of LVS-NAT model
1. NAT technology rewrites the address of both the request message and the response message through LVS, so when the website traffic is relatively large, the LVS load balancer has a big bottleneck, which generally requires up to 10-20 nodes.
2. You only need to configure a public network IP address on LVS. (NAT can also be implemented through iptables rules, so that private network addresses can also be used.)
3. The gateway address of each internal node server must be the intranet address of the scheduler LB. (if the DIP and RIP of LVS are on the same LAN and on the same network segment, you do not need to specify a gateway)
4. NAT mode supports translation of IP addresses and ports. That is, the port requested by the user and the port of the real server can be inconsistent.
LVS-DR mode (direct routing)
LVS-DR:Direct Routing, direct routing, LVS default mode, is the most widely used. It is forwarded by re-encapsulating a MAC header for the request message. The source MAC is the interface MAC where the DIP is located, and the destination MAC is the MAC address of the interface where the RIP of a selected RS is located. The source IP/PORT and destination IP/PORT remain unchanged.
The DR model, the request message, and the response message do not follow the same path. The request message is sent to RS through LVS. When the response message responds, it does not need to return the original path, it can be returned directly to the client.
The biggest benefit of this model is that there is less pressure on LVS services. Because only the request message needs to be sent to the RS server through the VS server, while the response message of the RS server is sent directly to the client without going through the LVS server. And the general request message is much smaller than the response message. This makes the LVS server much less stressful.
LVS-DR schema diagram
Because the RS server needs to send the request message directly to the client, and the IP accessed by the client is VIP, only the packet client from VIP will receive it, so we need to configure VIP on the RS server as well. But in this way, both LVS and RS have the same IP, which leads to the problem of address conflicts. We need to solve the problem of address conflicts.
We need to modify kernel parameters on RS to limit arp advertisements and response levels
/ proc/sys/net/ipv4/conf/all/arp_ignore
/ proc/sys/net/ipv4/conf/all/arp_announce
DR model features: the pressure of LVS is small, scheduling and forwarding can be achieved by changing the MAC address, and the port number can not be mapped.
The process of packet transfer in LVS-DR mode
LVS-TUN mode
Forwarding method: do not modify the IP header of the request message (source IP is CIP, destination IP is VIP), but encapsulate an IP header in addition to the original IP message (source IP is DIP, destination IP is RIP), and send the message to the selected destination RS;RS to respond directly to the client (source IP is VIP, destination IP is CIP)
(1) DIP, VIP and RIP should all be public network addresses
(2) generally, the gateway of RS cannot point to DIP.
(3) the request message goes through Director, but the response does not go through Director.
(4) Port mapping is not supported
(5) the OS of RS must support the tunnel function.
LVS-TUN architecture
IP packet scheduling process of LVS-TUN
LVS-FULLNAT mode
Lvs-fullnat: forward by modifying both the source IP address and the destination IP address of the request message
CIP-- > DIP
VIP-- > RIP
(1) VIP is a public network address, while RIP and DIP are private network addresses, and they are usually not on the same IP network. Therefore, the gateway of RIP generally does not point to DIP.
(2) the source address of the request message received by RS is DIP, so you only need to respond to DIP;, but Director also sends it to Client.
(3) request and response messages are all via Director
(4) Port mapping is supported
Summary of LVS working Mode
Ten scheduling modes of LVS
The scheduling of LVS is divided into static method and dynamic method.
Static method
Static method: scheduling only based on the algorithm itself
1. RR:roundrobin, polling, that is, requests are allocated sequentially. Even if a machine has poor performance or downtime, the request will be assigned to this host.
2. WRR:Weighted RR, weighted polling, differs from RR in that it can assign tasks according to server performance by setting weights on each RS server. There are more tasks with good performance and fewer tasks with poor performance. There will be the same shortcomings as RR.
3. SH:Source Hashing, to implement session sticky. The source IP address hash; will always send requests from the same IP address to the RS in the first pick, thus realizing session binding.
4. DH:Destination Hashing; destination address hash, the first polling is dispatched to RS, and subsequent requests sent to the same destination address are always forwarded to the RS selected for the first time. Typical usage scenarios are load balancers in forward proxy caching scenarios, such as broadband operators.
Dynamic method
Dynamic method: scheduling is mainly based on the current load state of each RS and the scheduling algorithm. The RS with smaller Overhead=value will be scheduled.
1. LC:least connections is suitable for long-connection applications.
Overhead=activeconns*256+inactiveconns
2. WLC:Weighted LC, the default scheduling method
Overhead= (activeconns*256+inactiveconns) / weight
3. SED:Shortest Expection Delay. High weight of initial connection is preferred.
Overhead= (activeconns+1) * 256/weight
4. NQ:Never Queue, the first round is evenly distributed, and the subsequent SED
5. LBLC:Locality-Based LC, dynamic DH algorithm, usage scenario: implement forward proxy according to load status
6. LBLCR:LBLC with Replication, LBLC with replication function to solve LBLC load imbalance
Problems, from heavily loaded copy to light loaded RS
Overhead indicates priority,
The number of connections that activeconns is in
Number of inactiveconns inactive connections
Weight weight
Advantages and disadvantages of LVS
Advantages:
Lvs is a kernel-level function, and its concurrency is quite large, which can reach millions of concurrency.
Disadvantages:
There is no so-called high availability feature, and the health of the back-end server cannot be checked. (the back-end server is down, and lvs has no way to manage it)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.