Basic knowledge of LVS

Source: Internet
Author: User

IP Virtual Server Software Ipvs

In the implementation of scheduler technology, IP load Balancing technology is the most efficient. In the existing IP load balancing technology, a set of servers are made up of a high-performance, high-availability virtual server through Network address translation (Addresstranslation), which we call Vs/nat technology (virtual server via Network addresstranslation), most commercially available IP load Balancer Scheduler products Use this method, such as Cisco's LocalDirector, F5 big/ip, and Alteon acedirector. On the basis of analyzing the disadvantage of vs/nat and the asymmetry of network service, we propose the method of implementing virtual server through IP tunneling Vs/tun (virtualserver via IP tunneling) and the method of implementing virtual server through direct routing vs/ DR (Virtual Server via directrouting), which can greatly improve the scalability of the system. So, the Ipvs software implements these three IP load balancing techniques, which are roughly the same as the following (we'll describe in detail how they work in other chapters),

    1. Virtual Server via Network Address translation (Vs/nat)
      Through the network address translation, the scheduler rewrites the target address of the request message, assigns the request to the backend real server according to the preset scheduling algorithm, and the response message of the real server passes through the scheduler, the source address of the message is rewritten and returned to the customer to complete the load scheduling process.

    2. Virtual Server via IP tunneling (Vs/tun)
      When using NAT technology, because the request and response packets must be rewritten by the dispatcher address, the processing power of the scheduler becomes a bottleneck when the customer requests are more and more. To solve this problem, the scheduler forwards the request message through the IP tunnel to the real server, and the real server returns the response directly to the client, so the scheduler only processes the request message. Since the General Network Service response is much larger than the request message, the maximum throughput of the cluster system can be increased by 10 times times with Vs/tun technology.

    3. Virtual Server via Direct Routing (VS/DR)
      The VS/DR sends the request to the real server by overwriting the MAC address of the request message, and the real server returns the response directly to the customer. As with Vs/tun technology, VS/DR technology can greatly improve the scalability of the cluster system. This method does not have the overhead of IP tunneling, and there is no need to support the IP tunneling protocol for real servers in the cluster, but requires that the scheduler and the real server have a NIC attached to the same physical network segment.


For different network service requirements and server configuration, the Ipvs Scheduler implements the following eight load scheduling algorithms:

  1. Call (Round Robin)
    The scheduler uses the "round-robin" scheduling algorithm to sequentially allocate external requests to real servers in the cluster, and treats each server equally, regardless of the actual number of connections and system load on the server.

  2. Weighted round call (Weighted Round Robin)
    The scheduler uses the "Weighted round call" scheduling algorithm to schedule access requests based on the different processing capabilities of the real server. This ensures that the processing capacity of the server handles more access traffic. The scheduler can automatically inquire about the load of the real server and adjust its weights dynamically.

  3. Minimum link (Least Connections)
    The scheduler dynamically dispatches network requests to the server with the fewest number of links established through the "least connection" scheduling algorithm. If the real server of the cluster system has similar system performance, the "Minimum connection" scheduling algorithm can be used to balance the load well.

  4. Weighted least link (Weighted Least Connections)
    In the case of the server performance difference in the cluster system, the scheduler uses the "Weighted least link" scheduling algorithm to optimize the load balancing performance, and the server with higher weights will bear a large proportion of active connection load. The scheduler can automatically inquire about the load of the real server and adjust its weights dynamically.

  5. Minimal links based on locality (locality-based Least Connections)
    The "least link based on locality" scheduling algorithm is a load balancing target IP address, which is mainly used in cache cluster system. According to the target IP address of the request, the algorithm finds the most recently used server, if the server is available and not overloaded, sends the request to the server, if the server does not exist, or if the server is overloaded and has half of the workload of the server, the principle of "least link" is used to select an available server. , the request is sent to the server.

  6. Local least-link-based (locality-based Least Connections with Replication) replication-basedminimal link scheduling algorithm is also load balanced against the destination IP address. It is mainly used in cache cluster system. It differs from the LBLC algorithm in that it maintains a mapping from a destination IP address to a set of servers, while the LBLC algorithm maintains a mapping from a destination IP address to a server. According to the target IP address of the request, the algorithm finds the corresponding server group of the target IP address, selects a server from the server group according to the principle of "minimum connection", if the server is not overloaded, sends the request to the server, if the server is overloaded, select a server from this cluster according to the "minimum connection" principle. Join the server to the server group and send the request to the server. Also, when the server group has not been modified for some time, the busiest server is removed from the server group to reduce the degree of replication.

  7. Destination Address hash (Destination Hashing)
    The target address hash scheduling algorithm finds the corresponding server from a statically allocated hash table, based on the requested destination IP address, as a hash key (HashKey), and if the server is available and not overloaded, sends the request to the server, otherwise it returns NULL.

  8. Source Address hash (source Hashing)
    The "Source address hash" Scheduling algorithm finds the corresponding server from a statically allocated hash table based on the requested source IP address, as a hash key (HashKey), and if the server is available and not overloaded, sends the request to the server, otherwise it returns NULL.


Common architecture for LVS clusters

As a general example, the LVS cluster uses a three-tier structure and the three-tier main components are:

    • load Balancer, which is the entire cluster to the outside of the front end machine, is responsible for sending the customer's request to a set of servers to execute, and the customer believes that the service is from an IP address (we can call the virtual IP address) on the.

    • Server Pool, a set of servers that really perform customer requests, such as Web, MAIL, FTP, and DNS.

    • shared storage, which provides a shared storage area for a server pool, makes it easy to have the same content for the server pool and provide the same service.


Comparison of the advantages and disadvantages of three methods

The pros and cons of three IP load balancing technologies are summarized in the following table:

_ vs/nat vs/tun vs/dr
server any non-arp device
server network private lan/wan lan
server number low (10~20) High (+) high (+)
Server gateway Load Balancer own router

Note: The estimation of the maximum number of servers supported by the above three methods is assumed that the scheduler uses a 100M network adapter, the hardware configuration of the scheduler is the same as the hardware configuration of the back-end server, and is for the general Web services. With higher hardware configurations (such as gigabit NICs and faster processors) as the scheduler, the number of servers that the scheduler can dispatch increases accordingly. When the application is not the same, the number of servers changes accordingly. Therefore, the above data estimates are mainly for the scalability of three methods of quantitative comparison.

Virtual Server via NAT

The advantage of Vs/nat is that the server can run any TCP/IP-enabled operating system, it only needs an IP address configured on the scheduler, and the server group can use a private IP address. The disadvantage is that its scalability is limited, when the number of server nodes rise to 20 o'clock, the scheduler itself may become a new bottleneck in the system, because in Vs/nat request and response messages are required through the load scheduler. We measured the average delay of the rewritten message at 60US on the host on the Pentium 166 processor, and the latency on the processor with higher performance was shorter. Assuming that the average length of the TCP message is 536 Bytes, the maximum throughput of the scheduler is 8.93 mbytes/s. Let's assume that the throughput of each server is 800KBYTES/S, so a scheduler can drive 10 servers. (Note: This is the data measured long ago)

The Vs/nat-based cluster system can be adapted to the performance requirements of many servers. If the load scheduler becomes a new bottleneck in the system, there are three ways to solve this problem: mixed methods, Vs/tun, and VS/DR. In a DNS hybrid cluster system, there are several Vs/nat load schedulers, each with its own cluster of servers, and these load schedulers form a simple domain name through Rr-dns. But Vs/tun and VS/DR are a better way to improve system throughput.

For those network service that transmits IP address or port number in the message data, the corresponding application module should be written to convert the IP address or port number in the message data. This brings the amount of work implemented, while the application module checks the packet overhead to reduce the throughput of the system.

Virtual Server via IP tunneling

In the Vs/tun cluster system, the load scheduler only dispatches requests to a different back-end server, and the back-end server returns the answered data directly to the user. In this way, the load scheduler can handle a large number of requests, it can even dispatch more than hundred servers (the same size of the server), and it will not become a system bottleneck. Even if the load scheduler has only 100Mbps full-duplex NICs, the maximum throughput for the entire system can exceed 1Gbps. Therefore, Vs/tun can greatly increase the number of servers dispatched by the load scheduler. The Vs/tun Scheduler can dispatch hundreds of servers, which in itself do not become a bottleneck in the system and can be used to build high-performance super servers.

Vs/tun technology requires the server that all servers must support an "IP tunneling" or "IP Encapsulation" protocol. Currently, Vs/tun's backend servers are primarily running Linux operating systems, and we are not testing other operating systems. Because IP tunneling is becoming the standard protocol for each operating system, Vs/tun should apply to back-end servers running other operating systems.

Virtual Server via Direct Routing

As with the Vs/tun method, the VS/DR scheduler only handles client-to-server connections, and the response data can be returned directly from a separate network route to the customer. This can greatly improve the scalability of the LVS cluster system.

Compared with Vs/tun, this method does not have the overhead of IP tunneling, but requires that the load scheduler and the actual server have a NIC attached to the same physical network segment, the server network device (or device alias) does not make ARP response, or can redirect the message (Redirect) to the local socket port.





This article is from the "topspeed_king" blog, make sure to keep this source http://mylinuxlife.blog.51cto.com/4706737/1659941

Basic knowledge of LVS

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.