Cluster Generation 2 (LVS algorithm)

Source: Internet
Author: User
When a ctor receives a incoming request and finds that it accesses a cluster service, it selects a backend server node to respond to the request according to a certain standard, this selection mechanism is the lvs scheduling algorithm. (1) Static scheduling method fixedscheduling does not...

When a ctor receives a incoming request and finds that it accesses a cluster service, it selects a backend server node to respond to the request according to a certain standard, this selection mechanism is the lvs scheduling algorithm.
(1) Static scheduling method fixed scheduling
Do not care about the active or inactive status of the current connection. do not check the connection status of realservers.
Algorithm:
1. Round-Robin Scheduling)
The round-call scheduling algorithm schedules requests to different servers in turn in the round-call mode, and then processes the requests accordingly. the advantage of this algorithm is its simplicity, it does not need to record the status of all current connections, so it is a stateless scheduling.
2. Weighted Round Scheduling (Weighted Round-Robin Scheduling)
The weighted round robin algorithm is used to differentiate the response capability of backend servers. the higher the weight, the more connections are allocated, which can solve the problem of different performance between servers. it uses the corresponding weights to indicate the processing performance of servers, the default server weight is 1. If the weight of server A is 1 and that of server B is 2, the processing performance of server B is twice that of server. Requests are distributed to each server based on the weights and the call method. servers with high weights receive connections first, servers with higher weights process more connections than servers with lower weights. servers with the same weights process the same number of connections.
3. Destination Hashing Scheduling)
The target address hash algorithm uses the target address as the standard and performs targeted forwarding on requests from the target address. This allows you to forward requests from the same user to the same server (based on the cache architecture, it can increase the cache hit rate). it uses a Hash function to map a target IP address to a server. The target address Hash scheduling algorithm first uses the target IP address of the request as the Hash Key to find the corresponding server from the static allocation Hash list, if the server is available and is not overloaded, send the request to the server. otherwise, null is returned.
4. Source Hashing Scheduling)
SOURCE address hash, based on the source address, forwards users from the same address to the same network. the algorithm is opposite to the target address hash scheduling algorithm. based on the source IP address of the request, as the Hash Key, the corresponding server is located from the static distribution Hash list. if the server is available and not overloaded, the request is sent to the server; otherwise, null is returned. It uses the same hash function as the target address hash scheduling algorithm. Its algorithm flow is basically similar to the target address hash scheduling algorithm. In practical applications, source address hash scheduling and target address hash scheduling can be used in a firewall cluster to ensure the unique entrance and exit of the entire system.
Static scheduling algorithm defect: the current status of the backend server cannot be considered
(2) dynamic scheduling method dynamic scheduling
Advantage: it is more reasonable to allocate requests based on the number of active connections of the backend server. This prevents one server from having too many loads while the other server is idle.
Two standards:
Inactive connection (but still in connection status)
Number of active connections
For example, ssh and telnet are both status-based connections, which need to be checked in real time, while hhtp is a stateless connection.
Corresponding algorithms:
1. Least-Connection Scheduling)
Least connection scheduling allocates new connection requests to the server with the smallest number of connections. it estimates the server load by the number of active connections on the server. The scheduler needs to record the number of established connections on each server. when a request is scheduled to a server, the number of connections increases by 1. when the connection is terminated or times out, the number of connections decreases by one. Check the number of inactive connections and the number of inactive connections at the same time. based on overhead, whoever overhead is small will accept the next request.
Example: overhead = number of connections in the active state * 256 + number of connections in the inactive state
2. Weighted Least-Connection Scheduling)
The weighted least connections (WLC) is the superset of the minimum connection scheduling. each server uses the corresponding weights to indicate its processing performance. The default server weight is 1. the system administrator can dynamically set the server weight. Weighted least connection scheduling is the most common algorithm to make the established connections on the server proportional to their weights when scheduling new connections. Example: overhead = (number of currently active connections x 256 + number of currently inactive connections)/weight
3. Shortest Expected Delay Scheduling SED)
The shortest expected latency is an improvement of the wlc algorithm. the number of inactive connections is not checked, and the number of inactive connections must be increased by one when calculating overhead.
Example: overhead = (number of connections in the current active State + 1) * 256)/weight
4. minimal Queue Scheduling (Never Queue Scheduling NQ)
At least the number of inactive connections is not checked during queue scheduling. only the active status is checked to ensure that the host is not idle. no queue is required. If the number of connections of a realserver is equal to 0, it is directly allocated. sed is not required.
5. Locality-Based Least Connections Scheduling)
The locality-based least-link algorithm is similar to the dh algorithm. it is a dynamic algorithm. it is used for round tuning based on the actual background conditions and supports weight based on the wlc. Currently, it is mainly used in Cache cluster systems, in the Cache cluster, the target IP address of the customer request message changes. If any backend server can process any request, the algorithm is designed to schedule requests with the same IP address to the same server when the server load is basically balanced, to improve the access locality and master Cache hit rate of each server, so as to process the entire cluster system. The LBLC scheduling algorithm first finds the server recently used by the target IP address of the request. if the server is available and is not overloaded, the request is sent to the server. if the server does not exist, alternatively, if the server is overloaded and has half of the server's workload, select an available server based on the "least link" principle and send the request to the server.
6. Locality-Based Least Connections with Replication Scheduling)
The local least link with replication is also used for load balancing of the target IP address. Currently, it is mainly used in Cache cluster systems. It differs from the LBLC algorithm in that it maintains a ing from a Target IP address to a group of servers, while the LBLC algorithm maintains a ing from a Target IP address to a server. For service requests from a "popular" site, a Cache server may be too busy to process these requests. At this time, the LBLC scheduling algorithm selects a Cache server based on the "minimum connection" principle from all the Cache servers and maps the "hot" site to this Cache server, soon this Cache server will be overloaded and will repeat the above process to select a new Cache server. In this way, the images of this popular site may appear on all the Cache servers, reducing the efficiency of the Cache server. The LBLCR scheduling algorithm maps "popular" sites to a group of Cache servers (server sets). when the request load of the "popular" site increases, the Cache server in the set is added, to process the increasing load. when the request load of the popular site is reduced, the number of Cache servers in the set is reduced. In this way, the images of the "popular" site are unlikely to appear on all the Cache servers, so as to provide the efficiency of using the Cache cluster system. The LBLCR algorithm first finds the server group corresponding to the target IP address based on the requested target IP address, and selects a server from the server group based on 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 based on the "minimum connection" principle, add the server to the server group, and send the request to the server. At the same time, when the server group has not been modified for a period of time, delete the busiest server from the server group to reduce the degree of replication.
Author: "Long Marks"

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.