By Abdulaziz Gebril, Alibaba Cloud Community Blog author
This tutorial is the second part of the two-part series on how to configure Load Balancer for ECS instances created by using Alibaba Cloud Starter Package. In this tutorial, we will show you how to set up the Server Load Balancer for the ECS instances launched while explaining the preceding part of this tutorial series.
Server Load Balancer (SLB) service improves your applications' performance by forwarding traffic to multiple ECS instances. By distributing traffic, it extends the servicing capability of applications. SLB also helps in eliminating single points of failure (SPOFs) to improve the availability of applications.
To get started with the SLB services, you must understand the following three key components of SLB:
1. SLB Instances: SLB instance distributes incoming traffic to backend servers. To use the Server Load Balancer service, you must create an SLB instance, and configure it with at least one listener and two backend servers.
The cost for an SLB instance is calculated using the Pay-As-You-Go billing method and is computed based on your actual traffic usage. For more detailed information, refer Server Load Balancer Pricing.
2. Listeners: Once the SLB instance is created, you must configure one or more listeners for the same. A listener checks for connection requests and forwards the requests to backend servers.
- <strong>Listener Protocol</strong>: SLB supports HTTP, HTTPS, TCP, and UDP protocols.
- <strong>Listening Port</strong>: It is used to receive requests and forward it to backend servers.
3. Backend Servers: After configuring the listener, you need to add some ECS instances as the backend servers for your SLB instance to respond to the distributed client requests.
- <strong>Port of Backend Servers</strong>: The port opened on the backend server to receive requests. It can be the same in an SLB instance.
- <strong>Weight of Backend Servers</strong>: An ECS instance with a higher weight value receives more requests. Setting the weight value to zero is equal to removing the ECS instance from Server Load Balancer.
In case, a listener is not associated with a custom server group, then by default, requests are forwarded to ECS instances in the default server group.
You can set the custom server groups in the listener via VServer group mode. VServer Groups also helps to meet the requirements of domain forwarding and URL redirections.
Log in to your Alibaba Cloud Console and click on the menu icon beside the Alibaba Cloud's logo, to view all the Alibaba Cloud Products.
Under the Elastic Computing section, click on Server Load Balancer and in the top navigation bar, select the region of your ECS instance.
If you haven't created an SLB instance in this region, you will get the following message:
Click on Create Instance and proceed with providing specifications to create your SLB instance.
Instance Spec: Select a performance specification for your SLB instance. The performance varies by the specification. For a shared-performance instance, performance is not guaranteed and resources are shared by all instances. The other instances provide guaranteed performance metrics and are opposite to a shared-performance instance. There are three key performance metrics for guaranteed-performance SLB instances:
When any of these metrics reach the limit of the specification, new connection requests will be dropped.
Now, review the fees of the service, and then click on the Buy Now button.
The next screen will show your chosen SLB ECS configuration. Review your choices, and confirm that you have read and agree to the Server Load Balancer Agreement of Service, then click on the Activate button to complete the order.
In the two subsequent sections, we will discuss how to configure the SLB instance to forward and distribute the HTTP/HTTPS Traffic to our previously launched ECS instances.
Please follow one of the following two configurations, either HTTP or HTTPS Traffic forwarding on SLB instance.
To configure HTTP Traffic Forwarding on your SLB Instance, create an HTTP Listener by following the steps below:
Step1: In the left-side navigation menu, choose Instances > Server Load Balancer. Once you are on the Server Load Balancer page, click Configure Listener in the Actions column.
Step 2 - Protocol and Listener: Select HTTP as the listener protocol and set the listening port to 80, then click on Next.
Step 3 - Backend Servers: Select VServer Groups, and then click Create VServer Group under the Select Server Group section. Enter a name for the VServer Group to be created and click on the Add button under the Servers Added section.
Step 3.a: In the Available Servers window, you will see a list of your ECS instances in a particular SLB instance region. Select your ECS instances to add, and click on the Next: Set Weight and Port button.
Step 3.b: Set the Weight and Port for each added ECS instance, and click on the Next button.
Step 4: By default, Enable Health Check options are checked, and it is recommended to keep it in that way. Click on the Next button.
Step 5: Review your configuration details, and make changes if needed, and then click Submit. I the end, click OK to close the dialogue box to return to the management console.
Follow the steps below to configure HTTPS traffic forwarding on your SLB instance:
Step1 - Upload Your SSL Certificate: Firstly, upload a server certificate by clicking on Certificates in the left-side navigation menu. SLB supports the certificates from Alibaba Cloud SSL Certificates Service or a third-party server certificate.
Click on Create Certificate and select a certificate from Alibaba Cloud SSL Certificates Service or Upload a Third-party Certificate
Step 2 - Create an HTTPS Listener: In the left-side navigation menu, choose Instances > Server Load Balancer. Next, on the Server Load Balancer page, find the SLB instance, and click Configure Listener in the Actions column.
Step 3 - Protocol and Listener: Select HTTPS as the listener protocol and set the listening port to 443, then click on Next.
Step 4 - SSL Certificates: Select the Server Certificate you have uploaded and click on Next.
Step 5 - Backend Servers: Select VServer Groups and click Create VServer Group under the Select Server Group section. Enter a name for the VServer Group to be created and click on Add under the Servers Added section.
Step 5.a: In the Available Servers window, you will get a list of your ECS instances in the selected SLB instance region. Select your ECS instances to add, and click on Next: Set Weight and Port button.
Step 5.b: Set the Weight and Port for each added ECS instance, and click on the Next button.
Step 6 - Health Check: By default, Enable Health Check options are checked, and it is recommended to keep it in that way. Click on the Next button.
Step 7 - Submit: Review your configuration details, and make changes if needed, and then click Submit. I the end, click OK to close the dialogue box to return to the management console.
For redirecting HTTP to HTTPS, you need to create an HTTP Listener by clicking Configure Listener in the Actions column on the Server Load Balancer page and following the below steps:
Step 1 - Protocol and Listener: Select HTTP as the listener protocol, set the listening port to 80, and click on Modify in the Advanced section. Enable Redirection and select HTTPS:443 as the target port, then click on Next.
Step 2 - Submit: Confirm and click Submit to redirect all the HTTP requests to the HTTPS listener and distribute them according to the listener configurations of the HTTPS listener.
Server Load Balancer supports domain name-based and URL-based forwarding rules to forward requests with different domain names or URLs to various backend servers. It helps to process the client's requests for your service using your domain names instead of the public IP address of your SLB instance.
To add a domain name-based or URL-based forwarding rule, Click the ID of the SLB instance.
Now click the Listeners tab to find the HTTP/HTTPS listener and then click the Routing Method in the Actions column.
In the Add Forwarding Rules window, enter the Domain Name/URL of the requests to be forwarded, select the VServer Group, and then click Add Forwarding Rules. After adding the respective rules, click OK.
To resolve a domain name to the public IP address of an SLB instance, you must point it by setting a DNS A
record for your domain to the public IP address of the SLB instance.
The DNS record would look like:
yourdomain.com. IN A SLB_PUBLIC_IP
www.yourdomain.com. IN A SLB_PUBLIC_IP
That's it! You have successfully configured Server Load Balancer for your ECS instances. To test your configuration, open your browser and hit the instance.html
page that we have previously created for each ECS instance, using the domain name or the public IP address of your SLB instance as follows:
http://SLB_PUBLIC_IP/instance.html
http://SLB_DOMAIN_NAME/instance.html
Since the load balancer is distributing the traffic to your ECS instances, you will get different instance names while hitting the instance.html
page several times.
Load Balancing Between Starter Package ECS Instances: Part 1
In Search of the Quick Win: Easy Steps to Enhance Services for Your Customers
2,599 posts | 765 followers
FollowAlibaba Clouder - October 25, 2019
Alibaba Clouder - January 25, 2021
Alibaba Cloud Community - May 6, 2024
Alibaba Clouder - June 2, 2020
Alibaba Clouder - May 29, 2020
Alibaba Clouder - August 11, 2020
2,599 posts | 765 followers
FollowLearn More
Learn More
Elastic and secure virtual cloud servers to cater all your cloud hosting needs.
Learn MoreMore Posts by Alibaba Clouder
5372730780198632 January 2, 2020 at 9:20 am
Dear Alibaba, After I success uploading SSL Certificate (both CA Certificate and Server Certificate) and set up http listener on load balancer, I end up getting this message on my browser, please help400 Bad RequestNo required SSL certificate was sentnginx
Alibaba Clouder April 20, 2020 at 5:53 am
Hi, there. You can create a ticket in your Alibaba Cloud console and our postsales team will help you with that. You can refer to the link below for the instruction of creating ticket: https://www.alibabacloud.com/help/doc-detail/47605.htm