All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Forwarding modes

Last updated:2021-05-26 16:59:41

Forwarding modes refer to the algorithms used by SLB to distribute traffic to backend servers. By using different forwarding modes and assigning different weights to backend servers, you can obtain different traffic distribution results.

Weighted round robin

The weighted round robin algorithm distributes requests to backend servers in a specific sequence based on the weights of backend servers. You can assign weights to backend servers based on their processing capabilities. A backend server with a greater weight receives connections earlier and receives more connections. Two backend servers with the same weight receive the same number of connections.

Advantages: This algorithm is simple. It is a stateless scheduling algorithm because it does not record connection status information.

Disadvantages: If the time required for processing requests varies greatly, loads on backend servers may not be balanced.

Application scenarios: This algorithm is applicable to scenarios where each request takes almost the same period of time on a backend server. This algorithm is typically used for short-lived connection services such as HTTP.

Weighted least connections

Different requests from clients may take different periods of time on a backend server and the time differences may be great. If you use the round robin algorithm in this scenario, the number of connections on one server might be much greater than the number of connections on another server over time. In this case, load balancing is not achieved.

The least connections algorithm is a dynamic scheduling algorithm. It assesses the load on a server based on the number of active connections on the server. This algorithm records the number of active connections on each server. When it distributes a request to a backend server, it increases the number of active connections on the server by 1. When a connection on a server is closed or timed out, it decreases the number of active connections on the server by 1.

The weighted least connections algorithm improves the least connections algorithm by taking the processing capabilities of servers into account. A server with greater processing capabilities gets a greater weight and is assigned more service requests.

SLB uses the following rules to identify the backend server for the next request:

  1. Assume that a backend server has a weight of wi and its number of active connections is ci. The weighted least connections algorithm divides the number of active connections on a backend server by the weight of the backend server. If a single backend server has the smallest ci/wi value, SLB distributes the next request to the backend server.

  2. If two backend servers share the same smallest ci/wi value, SLB uses the weighted round robin algorithm to distribute requests to the backend servers.

Advantages: This algorithm can be used to schedule requests that consume a long period of time, such as FTP requests.

Disadvantages: This algorithm must record the number of active connections on each backend server. It is a stateful scheduling algorithm.

Application scenarios: This algorithm is applicable to scenarios where different requests from clients may take different periods of time on backend servers and the time differences may be great. This algorithm is typically used for persistent connection services. For example, if the time difference is at a level such as 2 ms or 2 seconds, we recommend that you use the weighted least connections algorithm for load balancing.

Primary/Secondary forwarding

If your business relies on the primary/secondary mode, you must use two backend servers and configure the primary/secondary forwarding policy.

One of the backend servers is used as the primary server and the other is used as the secondary server. When the primary server works normally, traffic is forwarded to the primary server. If the primary server fails, traffic is forwarded to the secondary server.

Limits

  1. Primary/Secondary server groups apply only to TCP and UDP listeners.

  2. A primary/secondary server group contains only two backend servers, one of which is used as the primary server and the other is used as the secondary server.

  3. After the primary/secondary forwarding policy is configured, other forwarding policies cannot be used.

  4. In primary/secondary forwarding mode, the session persistence configuration does not take effect.

Note:

Only the following regions support primary/secondary forwarding:

  • CN East 1 (Shanghai)
  • CN South 1 (Guangzhou)
  • CN North 1 (Beijing)
  • CN North Finance 1 (Beijing)
  • CN East Finance 1 (Shanghai)
  • CN North Government 1 (Beijing)
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback