After you replicate Elastic Compute Service (ECS) instances to multiple zones, you can create a multi-zone Classic Load Balancer (CLB) instance in a region that supports multiple zones and associate ECS instances from different zones with the CLB instance. This way, you can extend the external service capabilities of application systems, eliminate single points of failure, and improve the availability of application systems. This topic describes how to deploy a CLB instance.

Prerequisites

  • Three ECS instances are created by replicating a source ECS instance. For more information, see Replicate ECS instances.
  • The web services of the four ECS instances are started and run as expected.
    Important If the web service of an ECS instance does not run, the ECS instance cannot communicate with a CLB instance.

Procedure

  1. Create a CLB instance. For more information, see Create a CLB instance.
    Configure the following parameters for the CLB instance:
    • Region: Select the region where the ECS instances reside.
    • Zone Type: Select Multi-zone.
    • SLB instance: Select Intranet.
    • Network Type: Select VPC.
    • Primary Zone and Backup Zone: Select zones based on your business requirements.
  2. Convert the public IP address of the source ECS instance into an elastic IP address (EIP). For more information, see Convert the public IP address of an instance in a VPC to an EIP.
    Note To prevent business from being affected, make sure that the IP address of the source ECS remains unchanged. Convert the public IP address of the source ECS instance into an EIP, disassociate the EIP from the source ECS instance, and then associate the EIP with the multi-zone CLB instance.
  3. Disassociate the EIP from the source ECS instance.
    1. In the IP Address column corresponding to the source ECS instance, click the EIP.
      EIP
    2. On the Elastic IP Addresses page, find the EIP and click Unbind in the Actions column.
    3. Click OK. For more information, see Disassociate an EIP from a cloud resource.
  4. Associate the EIP with the CLB instance.
    1. On the Elastic IP Addresses page, find the EIP.
    2. In the Actions column, click Associate with Resource.
    3. Select CLB Instance from the Instance Type drop-down list, select the CLB instance that you created, and then click OK. For more information, see Associate an EIP with an ECS instance.
  5. Configure the CLB instance. For more information, see Configure a CLB instance.
    Perform the following steps to configure the basic settings:
    1. In the Protocol and Listener step of the Configure Server Load Balancer wizard, configure the following parameters:
      • Select Listener Protocol: Select TCP.
      • Listening Port: Enter 80.
      • Scheduling Algorithm: Set this parameter based on your business requirements. In this example, Scheduling Algorithm is set to Round-Robin (RR).
      • Use the default values of the other parameters.
    2. Click Next. In the Backend Servers step, select Default Server Group. Then, click Add More to add ECS instances.
    3. In the panel that appears, select the source ECS instance and the three replicated ECS instances, click Next, and then click Add. Set Port to 80 and use the default values of other parameters. Click Next.
    4. In the Health Check step, use the default values of parameters and click Next.
    5. In the Confirm step, confirm the configurations and click Submit.
    6. Click OK to go back to the Instances page and then click refresh.
      If Normal is displayed in the Port/Health Check/Backend Server column corresponding to the CLB instance, the ECS instances in the default server group of the CLB instance work as expected and can receive requests that are forwarded by the CLB instance.
      Note The health check requires a few minutes to complete. Wait until the health check is complete and click the Refresh icon to check the Health Check value.

Result

In this topic, a static web page is built on each of the four ECS instances to identify each instance. Enter the IP address of the CLB instance in the address bar of a browser to test the load balancing performance of the instance. Requests are distributed to the ECS instances in turn because Scheduling Algorithm is set to Round-Robin (RR) for the listener.

What to do next

Migrate self-managed databases to ApsaraDB RDS instances that run RDS High-availability Edition