Three LVS Load Balancing modes and eight Scheduling Algorithms for LVS Load Balancing

Source: Internet
Author: User

Three LVS Load Balancing modes and eight Scheduling Algorithms for LVS Load Balancing

Three LVS Load Balancing Modes

In the implementation technology of the scheduler, the IP Server Load balancer technology is the most efficient, and the IP virtual server software (IPVS) is implemented in the Linux kernel 。

LVS Load Balancing mode-1. NAT Mode

NAT is used to convert an internal reserved IP address to an Internet address through ing because of insufficient network IP addresses. If the NAT process changes slightly, server Load balancer can be used. The principle is to replace the IP header destination address of the IP packet sent from the client with the IP address of one of the REALSERVER on the DR, the REALSERVER sends the data back to the client through the DR host after processing is completed. At this time, the original IP address of the data packet can be changed to the IP address on the DR interface, both incoming traffic and outgoing traffic must pass through DR 。

LVS Load Balancing mode-2. IP tunneling Mode

The Tunneling mode is similar to the VPN mode. Based on the network layering principle, a new IP header mark (incomplete IP header, only the destination IP address) is sent to the REALSERVER. After receiving the data packet, the REALSERVER unlocks the header of the data packet sent by the DR device, restores the original data packet, and then directly returns the data packet to the client, you do not need to go through DR. It is worth noting that because REALSERVER needs to restore the data packets sent by DR, that is, it must support the IPTUNNEL protocol. Therefore, in the REALSERVER kernel, you must compile the option that supports IPTUNNEL. IPTUNNEL is also in Net working options 。

LVS Load Balancing mode-3. Direct routing Mode

The direct routing mode is quite special. It is hard to say something similar. The first two modes basically work on the network layer (Layer 3 ), the direct routing mode should work on the data link layer (Layer 2). The principle is that both DR and REALSERVER use the same IP address for external services, but only DR responds to ARP requests, all realserver arp requests to the IP address remain silent. That is to say, the gateway directs all requests to the IP address of the Service to the DR. After receiving the data packet, the DR will follow the scheduling algorithm, find the corresponding REALSERVER, change the destination MAC address to the MAC address of the REALSERVER, and send it to the REALSERVER. When the REALSERVER receives this packet, it is equal to directly receiving this packet from the client, after processing, it is directly returned to the client. Because DR needs to change the L2 packet header, the DR and REALSERVER must be in the same broadcast domain or on the same vswitch 。

Eight Scheduling Algorithms for LVS Server Load balancer

LVS has implemented the following eight scheduling algorithms:

LVS load balancing algorithm --- 1. Round-Round Scheduling)

The scheduler uses the "Wheel call" scheduling algorithm to distribute external requests to the real servers in the cluster in turn in sequence. The scheduler treats each server equally, regardless of the actual number of connections and system load on the server 。

LVS load balancing algorithm --- 2. Weighted Round Scheduling (WeightedRound-weight scheduling)

The scheduler uses the Weighted Round call scheduling algorithm to schedule access requests based on different processing capabilities of the Real Server. This ensures that servers with high processing capabilities can process more access traffic. automatically inquire about the actual server load, and dynamically adjust its weight 。

LVS load balancing algorithm --- 3. Least-ConnectionScheduling)

The scheduler uses the "least connected" scheduling algorithm to dynamically schedule network requests to servers with the least established connections. If the real servers in the cluster system have similar system performance, the "minimal connection" scheduling algorithm can better balance loads 。

LVS load balancing algorithm --- 4. weighted least join Scheduling (WeightedLeast-ConnectionScheduling)

When the server performance in the cluster system is significantly different, the scheduler uses the "weighted least link" scheduling algorithm to optimize the Server Load balancer performance, A server with a higher weight will bear a large proportion of the active connection load. The scheduler can automatically query the actual server load and dynamically adjust its weight.

LVS load balancing algorithm --- 5. Locality-BasedLeastConnectionsScheduling)

The local least link scheduling algorithm is a load balancing algorithm for the target IP address. Currently, it is mainly used in the Cache cluster system. This algorithm finds the server closest to the target IP address based on the request's target IP address, if the server is available and is not overloaded, send the request to the server. If the server does not exist, or the server is overloaded and has half of the workload, select an available server based on the "minimum link" principle and send the request to the server 。

LVS load balancing algorithm --- 6. Local least link with replication (Locality-BasedLeastConnectionswithReplicationScheduling)

The local least link-Based Scheduling Algorithm with replication is also a load balancing algorithm for the target IP address, it is mainly used in the Cache cluster system. It differs from the LBLC Algorithm in that it maintains the ing from a target IP address to a group of servers, the LBLC algorithm maintains the ing from a target IP address to a server. The algorithm finds the server group corresponding to the target IP address based on the requested target IP address, select a server from the server group according to the "minimum connection" principle. If the server is not overloaded, send the request to the server. If the server is overloaded; select a server from the cluster according to the "minimum connection" principle, add the server to the server group, and send the request to the server, when the server group has not been modified for a while, delete the busiest server from the server group to reduce the degree of replication.

LVS load balancing algorithm --- 7. DestinationHashingScheduling)

Target address hash "the scheduling algorithm identifies the corresponding server from the static allocation hash list based on the target IP address of the request as the hash key. If the server is available and not overloaded, send the request to the server; otherwise, null is returned.

LVS load balancing algorithm --- 8. Source Address hash Scheduling (SourceHashingScheduling)

The source address hash "scheduling algorithm identifies the corresponding server from the static allocation hash list based on the requested source IP address as the hash key. If the server is available and not overloaded, send the request to the server. Otherwise, null is returned 。

LVS + Keepalived achieves layer-4 load and high availability

LVS + Keepalived high-availability server Load balancer cluster architecture Experiment

Heartbeat + LVS build a high-availability server Load balancer Cluster

Build an LVS load balancing test environment

A stress test report for LVS

This article permanently updates the link address:

Related Article

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.