LVS principle

Many documents are some related operations, for specific principles appears quite small, in order to better direction to go, then, we must understand the principle, the question arises, can quickly find the problem.

Share a classic dialogue:

Q: how do you deal with network failure? 

A: Experience from experience, no experience to go principle 

Q: If you take the principle still can not solve it? 

A: Because not enough in-depth understanding of the principles you ^ _ ^

Today, share a principle of LVS:

LVS load balancing three modes, namely VS / NAT (nat mode) VS / DR (Route mode) VS / TUN (tunnel mode)

LVS has ten scheduling algorithm:

1. round robin scheduling
2. Weighted round robin scheduling
3. Least Connection Scheduling
4. weighted least connections scheduling
5. least partially based connection
based on connection 6. Locality minimum band replication of
hash scheduled destination address 7.
8. Source hashing scheduling the U-
9. the shortest expected delay
10. the minimum scheduling queue

A, NAT mode (VS-NAT)

Principle: is the destination address of the IP header sent by the client data packet, wherein the IP address into a station RS on the load balancer

Concurrent so far to deal with RS, RS dealt with the data to the load balancer, the load balancer then the original packet IP address to its own IP

During the destination address to the client IP address can be either incoming traffic or outgoing traffic must go through the load balancer

  Advantages: a cluster of physical servers can use any support TCP / IP operating systems, load balancing requires only a valid IP address

  Cons: Limited scalability. When too many server nodes (ordinary PC server) growth, the load balancer will become the bottleneck of the whole system

Because all the request packets and response packets have been flowing to the load balancer. When too many server nodes

A large number of packets are in the intersection of the load balancer that, the speed will slow down!

 

Two, IP tunnel mode (VS-TUN)

How it works: First, you know, most of the Internet service request packet on the Internet is very short, and response packets usually large

Then the tunnel mode is, the client to the packet, a new IP header encapsulated marker (only the destination IP) issued RS

After the RS received first packet header untied restore data packets, after processing, returned to the client directly, you do not need to go through

Load balancer. Note that since the RS need to load balancer sent me a packet reduction, so that must be supported

IPTUNNEL agreement, so in RS kernel must be compiled to support this option IPTUNNEL

  Advantages: the load balancer is responsible for the request packet only distributed backend server node, the RS a response packet directly to the user

Therefore, reducing the amount of data flow in the load balancer, the load balancer is no longer the bottleneck of the system, it can handle the huge amount of request

In this way, a load balancer can be distributed to a lot of RS. And running can be distributed in different areas of the public Internet.

  Drawback: RS node tunnel mode requires legitimate IP, this approach requires all servers support the "IP Tunneling"

(IP Encapsulation) protocol, a server may only be limited to the part of the Linux system

 

Third, the direct routing mode (VS-DR)

Principle: The load balancer and RS use the same IP external services but only respond to ARP requests DR

All RS to own the IP of the ARP request that is keeping silent, the gateway will request for the service of all IP directed to the DR.

After the DR receives a data packet according to the scheduling algorithm, find the corresponding RS, the RS destination MAC address to a MAC (since the same IP)

After the request and distribute this case RS RS receives this packet, the processing is completed, since the same IP, the data may be directly returned to the client

Is then equal to the received data packet is no different from the client, returned to the client directly after treatment

Since the load balancer for a Layer 2 packet header change, it must be supported in a region between the equalizer and the broadcast RS

It can also be understood as a simple switch on the same

  Advantages: and TUN (tunnel mode), as only the load balancer to distribute the request response packet back to the client through a separate routing method

Compared with the VS-TUN, VS-DR tunnel structure does not require such an implementation, the operating system can be used most as a physical server.

  :( shortcomings can not say shortcomings, can only be said to be inadequate) requires the card must load balancer on the physical network card in a physical segment.

 

Guess you like

Origin www.cnblogs.com/jimmyTang-J/p/11596873.html
LVS
LVS
lvs
LVS
LVS