Common Load Balancing Methods

Source: Internet
Author: User

Http://publish.it168.com/2006/0315/20060315030001.shtml

1. DNS load balancing method

The RR-DNS (round-robin Domain Name System) takes turns by: In a DNS server,
You can configure the same name for multiple IP addresses. When the client queries this name, it will get an address when parsing this name. Therefore, for the same name, different clients will get different
To achieve load balancing. For example, when the client is connected
When the www.muti-ip.com.tw is named, DNS has the ability to sequentially resolve the name to 202.1.1.1, 202.1.1.2, 202.1.1.3 and
202.1.1.4 and other different network addresses, and these are hosts that provide the same service, so that the client does not consciously have a different

 2. server load balancing at the application layer and IP layer

Both Eddie, reverse-proxy, and sweb use the load balancing method at the application layer to forward incoming HTTP requests to different Web
Server, and then return the result to the user. Magicrouter of Berkeley, localctor ctor of Cisco, Altheon
Both acedirector and F5's big/IP address use the network address translation Nat method. Currently, the Cluster Method on Linux is also achieved using this method.

  3. How the Cluster Server balances the load

  The mechanism that clusters can achieve

A. The separation service concatenates more than two servers into a server group, and each server provides the same service

B. the hacker has a client and feels that only one machine is providing services.

C. backup capability, that is, when a server fails, there will be no service interruption.

D. scalability when the number of customers increases, servers can be expanded without service suspension

E. Server Load balancer scientifically allocates client requirements to servers, so as not to overload hosts

Linux cluster load balancing software ---- LVS (Linux virtual server)

  In Linux, the cluster is implemented by setting up Linux virtual server (LVS ).

LVS can be called a Linux virtual server. It has high availability, scalability, and scientific mathematical operations, and these are the applications of Cluster Systems.

High Availability high-availability (HA) does not allow the occurrence of service interruptions. More than two computers listen to each other in a certain way. When the service is stopped due to a problem on the main server host, the backup server can automatically take over immediately, make the client feel different.

Scalability applications in Web and FTP
Server. When a user links an address, several servers are actually providing services. When service requests reach saturation, it is easy to add new nodes without stopping the entire node.
Cluster to implement the so-called "Hot swapping", which is a concept in cluster-scalability
(Easy scalability ). In addition, the cluster will query the actual node status. When a real node does not respond, the task will not be assigned to it until the node returns to normal.

Scientific mathematical computation (scientific) is used for efficiency, image processing, and other computation.

Cluster has been developing for many years and is also quite mature. Professional software/hardware is required before implementation. Therefore, only a few companies can use it. Now Linux LVS allows you to set up cluster solutions on a PC, so that more people have the opportunity to build their own clusters.

LVS provides three forwarding mechanisms (Traffic forward mechanism) and four load-balancing methods.

Traffic forward Mechanism)

  Three different forwarding mechanisms create an LVS host

Nat virtual host virtual server via Network Address Translation
IP tunneling virtual host virtual server via IP tunneling
Direct routing virtual host virtual server via direct routing
A server Load balancer host can be called a virtual server (virtual host), A Load balancer (Load balancer), or a Linux ctor (pilot host ).

 Nat virtual server via Network Address Translation (Vs/NAT)

Due to the growing shortage of IP address space in IPv4 and security reasons, many networks use private IP addresses not allocated on the Internet.
(10.0.0.0/255.0.0.0, 172.16.0.0/255.128.0.0
And 192.168.0.0/255.255.0.0 ). To connect hosts in the internal network to the Internet or be connected by the Internet, you need to use Network Address Translation
(Network Address Translation, hereinafter referred to as Nat), you can use the NAT method to change the parallel network service of different IP addresses into an IP address
A virtual service on the address.

There is an LVS host in front of a group of servers.
Address (the external address of the LVS host) when connecting to the service, the request arrives at the LVS host. The LVS host selects one from a group of real servers by using the load balancing method, and sets the target address
Virtual IP
Address points to the address of the internal service provider. At the same time, the LVS host records the connection. When the response of the real server of the connection passes through the LVS host, The LVS host will
Change the address and source port? Virtual IP
Address and the corresponding port, and then send the response to the user. When the connection is terminated or terminated, the LVS host deletes the connection from the record. In this way, all you see is
Address.

  IP tunneling virtual host virtual server via IP tunneling (Vs/TUN)

In the VS/NAT cluster system, requests and responses are sent through the LVS host. When the number of servers exceeds 20, The LVS host becomes a new bottleneck in the cluster system. Exploitation
The IP tunneling technology encapsulates and forwards request packets to backend servers, and the response packets can be directly returned to customers from backend servers. But here, there is a group of backend servers rather than one, so we cannot establish them statically.
A one-to-one tunnel dynamically selects a server to encapsulate and forward request packets to the selected server. In this way, we can use the principle of IP tunneling to make the network services on a group of servers
The Virtual Network Service on the IP address.

Each server configures the VIP address on its own IP tunneling device.

The connection allocation and management of VS/TUN are the same as those in VS/NAT, but their packet forwarding methods are different. The server Load balancer host dynamically selects a service based on the load of each server.
To encapsulate the request packet in another IP packet, and then forward the encapsulated IP packet to the selected server. After the server receives the packet, first, unseal the packets to obtain the packets whose original destination address is VIP,
The server finds that the VIP address is configured on the local IP tunneling device. Therefore, the server processes the request and then directly returns the response packet to the customer based on the route table.

Direct routing virtual host virtual server via direct routing (Vs/DR)

This IP layer load balancing method is similar to that in IBM's netdispatcher.

Both the LVS host and server group must be in the same network area, such as through a switch or a high-speed hub. The VIP address is shared by the LVS host and server group.
VIP addresses are externally accessible and used to receive requests from virtual services. All servers configure their VIP addresses on their non-ARP network devices, it is invisible to the outside and is only used
Processing target address? VIP network request.

The connection allocation and management of VS/Dr are the same as those in VS/NAT and VS/TUN. The packet forwarding method is different, and packets are directly routed to the target server. In VS/DR
In, The LVS host dynamically selects a server based on the load of each server, and does not modify or encapsulate IP packets. Instead, the MAC address of the data packet is changed to the MAC address of the server, add
The modified data packet is sent on the LAN of the server group. Because the MAC address of the data packet is the selected server, the server can certainly receive the packet, the VIP address is configured on the local network.
Therefore, the request is processed and the response packet is directly returned to the customer according to the route table.

Advantages and disadvantages of the three forwarding mechanisms

Summarized in the following table:

● Virtual server via Nat

The advantage of VS/NAT is that the server can run any operating system that supports TCP/IP,
It only needs one IP address configured on The LVS host, and the server group can use a private IP address. The disadvantage is that it has limited scalability. When the number of server nodes increases to 20, The LVS host itself may become
This is a new bottleneck for the system, because in VS/NAT, request and response packets must both pass through the load LVS host. In Pentium
166 The average latency of overwrite packets measured on the host is 60us. Assuming that the average length of TCP packets is 536 bytes, the maximum throughput of the LVS host is 8.93.
Mbytes/s. Assuming that the throughput of each server is 600 Kbytes/s, such an LVS host can drive 16 servers.

● Virtual server via IP tunneling

In the VS/TUN cluster system, the load LVS host only distributes requests to different actual servers. The actual server directly returns the response information to the user. In this way, the load LVS host can process massive requests without becoming a system bottleneck. Even if the load LVS host only has Mbps full-duplex Nic,
The maximum throughput of a virtual server can reach several Gbps. Therefore, VS/TUN can greatly increase the number of servers allocated by the LVS host, which can be used to build high-performance super servers. VS
/TUN technology requires that all servers must support the "IP tunneling" or "IP Encapsulation" protocol. Currently, VS/TUN
The backend server is mainly running the Linux operating system. Because "ip
Tunneling is becoming a standard protocol for various operating systems. Therefore, VS/TUN is also applicable to backend servers running other operating systems.

● Virtual server via direct routing

Like VS/TUN, The Vs/drlvs host only processes the connection from the customer to the server, and the response data can be directly returned to the customer from an independent network route. This can greatly improve LVS
Scalability of the cluster system. Compared with VS/TUN, this method has no overhead of IP tunnel, but requires that the load LVS host and the actual server have a NIC connected to the same physical network segment, and the server network is set
The slave node or the device alias does not respond to ARP.

 Load-balancing methods)

Different allocation methods build LVS hosts into four different Scheduling Methods

The load balancing schedule is in the unit of connection. In HTTP (Nowait), a TCP connection is required for each object obtained from the Web server. Different requests of the same user are allocated to different servers, therefore, the distribution of such connections completely avoids load imbalance caused by sudden user connections. There are currently four scheduling algorithms:

Round-Robin Scheduling (RRS)

The scheduling algorithm in turn assumes that all servers have the same processing performance and distribute requests to different servers in sequence. The algorithm is simple, but it is not applicable to scenarios where the processing performance in server groups is inconsistent.

Weighted Round Robin route Weighted Round-Robin Scheduling (wrrs)

Therefore, the weighted round-robin scheduling algorithm is used to indicate the server's processing performance with the corresponding weighted value, and the number of requests is allocated to each server in proportion to the weighted value. Servers with high weights receive connections first. servers with high weights process more connections than servers with lower weights. servers with the same weights process the same number of connections.

Minimum number of connections (LCS)

The minimum number of connections is to record the number of TCP connections established by each server, and send the new connection request to the server with the minimum number of connections. When each server has the same processing performance, the minimum number of connections can evenly distribute requests with large load changes to each server, all requests that have been processed for a long time cannot be sent to the same server.

Weighted Least connections schedule weighted least-connection Scheduling (WLCS)

However, when the processing capability of each server is different, this algorithm is not ideal because the TCP connection enters the time_wait status after processing the request, and the TCP time_wait
Generally 2 minutes, the connection still occupies server resources, so the high-performance server has processed the received connection, and the connection is in the time_wait status, while the low-performance server
You must be busy processing the received connections and receiving new connection requests. Weighted Least connection allocation is the superset of the minimum connection allocation. Each server uses the corresponding weights to indicate its processing performance. Assume the weight of each server
Is wi (I = 1 .. n), the number of TCP connections is Ti (I = 1 .. n). Select Ti/wi as the smallest server in sequence as the next server allocated to the service.

Load-balancing methods)

As follows:

Name Description

Round Robin (RRS)
Evenly distribute jobs to servers (used for consistent performance of actual service hosts)

Least-connections (LCS)
Allocate more work to servers with fewer connections (the ipvs table stores all active connections. Used for consistent performance of the actual service host .)

Weighted Round Robin (wrrs)
Allocate more work to large-capacity servers. It can be dynamically adjusted up or down based on the load information. (Used when the performance of the actual service host is inconsistent)

Weighted Least-connections (wlc)
Consider their capacity to allocate more work to less connected servers. The capacity can be dynamically adjusted up or down based on the load information. (Used when the performance of the actual service host is inconsistent)

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.