This article presents the essential considerations for configuring an SLB instance. Before you create an SLB instance, you must determine the types of listeners and the network traffic you want to balance.
When you select a region, note the following points:
- To reduce latency and increase the download speed, we recommend that you select a region closest to your end-users.
- SLB offers stable and reliable load balancing services by providing support for primary/secondary failovers in most regions. This implements disaster recovery across different zones within the same region. We recommend that you select a region that supports the primary/secondary SLB deployment.
- SLB instances cannot span across regions. Therefore, you must make sure that the SLB instance and its backend Elastic Compute Service (ECS) instances are located in the same region.
SLB provides load balancing services for both Internet and internal network traffic:
- If you need to use SLB to distribute requests from the Internet, you can create an
Internet-facing SLB instance.
An Internet-facing SLB instance comes with a public IP address to receive requests from the Internet.
- If you need to use SLB to distribute requests from the internal network, you can create
an internal SLB instance.
Internal SLB instances only have private IP addresses and are only accessible from the internal network and not from the Internet.
When you create an SLB instance, you can choose a guaranteed-performance instance or a shared-performance instance. The guaranteed-performance SLB instance provides greater flexibility in resource utilization to guarantee service availability. SLB provides six types of guaranteed-performance instances.
- For a pay-as-you-go SLB instance, we recommend that you select the instance type that provides the highest level of performance. This guarantees a flexible load balancing service without incurring any additional costs. However, if the capacity of Super I (slb.s3.large), the highest-performance instance type, far exceeds the demand of your business, you can select a more appropriate type based on the workload of your business, for example, Higher II (slb.s3.medium).
SLB supports Layer-4 load balancing of Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) traffic, and Layer-7 load balancing of HTTP and HTTPS traffic.
- A Layer-4 listener directly distributes requests to backend servers without modifying packet headers. After a client request reaches a Layer-4 listener, SLB uses the backend port configured for the listener to establish a TCP connection with an Elastic Compute Service (ECS) instance (backend server).
- A Layer-7 listener is implemented as a reverse proxy. After a client request reaches
a Layer-7 listener, SLB establishes a new TCP connection over HTTP to a backend server,
instead of directly forwarding the request to the backend server (ECS instance).
Compared with Layer-4 listeners, Layer-7 listeners require an additional step of Tengine processing. Therefore, Layer-4 listeners provide better performance than Layer-7 listeners. In addition, the performance of Layer-7 listeners can also be affected by factors such as insufficient client ports or excessive backend server connections. Therefore, we recommend that you use Layer-4 listeners for high-performance load-balancing services.
For more information, see Protocols.
Before you use the SLB service, you must create ECS instances, deploy applications on them, and add the ECS instances to your SLB instance to process client requests.
- Select a region and zone for the ECS instance
Make sure that the ECS instance resides in the same region and Virtual Private Cloud (VPC) as the SLB instance. We recommend that you deploy ECS instances in different zones to improve availability. For more information about how to create an ECS instance, see Create an instance by using the provided wizard.
In this example, two ECS instances named ECS01 and ECS02 are created in the China (Hangzhou) region. The following figure shows their basic configurations.
- Configure applications
In this example, two static web pages are built on ECS01 and ECS02 by using Apache.
No additional configuration is required after you deploy applications on the ECS instances. However, if you need to use a Layer-4 (TCP or UDP) listener and the ECS instances run on Linux, make sure that the following parameters in the net.ipv4.conf file under /etc/sysctl.conf are set to 0:
- Enter the Elastic IP address (EIP) associated with ECS01 in the address box of your browser.
- Enter the EIP associated with ECS02 in the address box.
net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.all.rp_filter = 0 net.ipv4.conf.eth0.rp_filter = 0