LVS is a server cluster solution based on Linux system, its goal is to create a good scalability, good reliability, high performance of a system, many commercial cluster products are based on LVS technology to achieve.
The core of LVS is to load balance through a set of servers, through the front-end load scheduler, the request seamlessly dispatched to the real server, then the client is not feel. Its scalability is to join or delete nodes in the cluster to achieve, by detecting the fault of the node or service process and the correct settings to achieve high availability of the system, because this load scheduling is done in the Linux kernel, so called Linux virtual server, Server, abbreviated as LVS.
We call the most front-end load balancer called DS, the director server, the backend of the actual server called real server, that is, RS, the IP virtual server software called Ipvs, that is, IP Vsan, And the IP load balancing technology is the most efficient. The technology of building a group of servers into a high-performance, highly available virtual server through NAT is called Vs/nat Technology, which is the virtual server via Network Address translation. The IP tunneling technology is the Vs/tun (virtual server via IP tunneling) and the method of searching for servers via direct routing vs/dr (virtual server via direct Routing), Both of these methods can greatly improve the scalability of the system. So, Ipvs software realizes three kinds of IP load balancing technology.
For the above three technologies, we summarize here, first of all, the NAT technology will certainly save the IP address, because it disguises the interior, but inefficient, because the traffic returned to the requester needs to pass the converter, its bottleneck is the dispatcher's processing power. The second is the IP tunneling technology, and the IP tunneling technology means that the dispatcher can forward the request message through the IP tunnel to the real server, in the real server to return the response directly to the customer, so that the scheduler only need to process the request message. Generally speaking, the response message is much larger than the request message, after using IP tunneling technology, the maximum throughput of the cluster system can be increased by about 10 times times, the IP tunneling technology realizes the virtual server usually in the cluster node, the mail service, the News service, the DNS service, the proxy service and so on. While the direct routing technology is to rewrite the MAC address of the request message, send the request directly to the real server, and then return the response directly to the customer by the real server, but it has less overhead than the IP tunneling technology, but it requires the scheduler and the real server through the network card link to the same physical network segment.
For the LVS of several algorithms, the first is polling, but it does not consider the actual number of server connections and system load situation, but also can be weighted polling, he will be based on the real server processing capacity to schedule access requests, so that the processing capacity of the server can handle more traffic. It can also be the least-connection algorithm, which is done by dispatching network requests to the server with the fewest number of established connections. Of course, it can also be a weighted least-connection algorithm, which is used to handle server performance gaps larger than the case. There is a minimum number of connections based on locality, which load balance the IP address of the target, it will automatically find the IP address of the most recently used server, if the server is available, then send the request to it, if the server does not exist, it will automatically invoke the principle of least connections. You can also use the address hashing algorithm, which is usually divided into the destination address hash and the source address hash. There are also sed and NQ algorithms, which are not introduced.
First of all, keepalived software, he is a similar to the Layer3, 4, 5 switch system software, that is, we say the 3rd layer, 4th layer, 5th layer Exchange. Its purpose is to detect the state of the server, if a server crashes or work failure, the software will detect it and remove it, when the server is working properly, he will add it to the server cluster, these are automatically completed, do not need our human intervention. The keepalived here is for the detection of RS and the implementation of failover between the LoadBalance host and the backup host.
The third layer of exchange it will send an ICMP packet like a server cluster server, that is, our ping program, if the IP address of a server is not activated, then our software will assume that the server is invalid, and it will be removed from the server cluster. In other words, this layer is based on whether the server's IP address is valid as a standard to determine whether the server is working properly. The fourth Exchange will use the status of the TCP port to determine whether the server is working properly, for example, our web server is typically port 80, which detects whether certain ports are being booted, and then determines if the servers will be removed from them. The fifth layer of exchange is more complex, so it occupies a higher bandwidth, it will be based on the user's settings to check whether the server program is working properly, if the user settings do not match, the server will be removed from the cluster.
Sinsing website Architect's notes second article