Deploy a high-availability computing cluster with a balanced policy

更新时间:
复制 MD 格式

Auto Scaling quickly provisions a computing cluster by distributing ECS instances across multiple availability zones with a balanced distribution policy, monitoring instance health in real time to ensure high availability. This tutorial walks through deploying a high-availability computing cluster and reducing resource costs with spot instances.

Use cases

Scenario

Distributed big data computing and AI training workloads often require a burst of computing resources during peak hours, making it essential to rapidly create a high-availability computing cluster.

For example, an online advertising provider that uses machine learning for ad targeting needs to scale up computing resources during peak traffic. Manually creating a cluster of ECS instances is slow and error-prone — you might face instance creation failures due to insufficient inventory in a single availability zone, or service disruptions if that zone fails.

Solution

Use Auto Scaling to automatically create ECS instances in bulk. The balanced distribution policy spreads these instances evenly across multiple availability zones, while spot instances help reduce your costs.

image

Benefits

This approach provides the following benefits:

  • Zero operational overhead

    Auto Scaling automatically scales your ECS instances in or out without manual intervention.

  • Built-in high availability

    The balanced distribution policy distributes ECS instances across availability zones, preventing scale-out failures caused by insufficient inventory in a single zone. The instance health check feature, enabled by default, ensures all ECS instances in the scaling group remain available.

  • Excellent cost-effectiveness

    Spot instances for compute nodes can significantly reduce resource costs.

Procedure

Note
  • Evaluate your business architecture and create a scaling group for the business modules that require a high-availability cluster.

  • Prepare a custom image with your business application already deployed. When you create a scaling configuration, select this custom image to ensure that the automatically created ECS instances meet your requirements. For more information, see Create a custom image from an instance.

  1. Log on to the Auto Scaling console.

  2. Create a scaling group.

    1. In the left-side navigation pane, click Scaling Groups.

    2. In the top navigation bar, select a region.

    3. In the upper-left corner of the page, click Create.

    4. On the Create by Form tab, configure the parameters for the scaling group and then click Create.

      The following table describes the parameters configured in this tutorial. For unlisted parameters, use the default settings. For more information about how to configure a scaling group, see Create a scaling group.

      Parameter

      Example

      Description

      Scaling Group Name

      test

      Enter a name for the scaling group. For information about the format requirements, see the on-screen instructions.

      Type

      ECS

      Select ECS to manage ECS instances in the scaling group.

      Instance Configuration Source

      Create from scratch

      Do not specify a template for automatic instance creation. After the scaling group is created, you must create a scaling configuration.

      Minimum Number of Instances

      100

      The minimum number of instances in the scaling group. If the number of instances falls below this value, Auto Scaling adds instances to meet this minimum.

      Maximum Number of Instances

      120

      The maximum number of instances in the scaling group. If the number of instances exceeds this value, Auto Scaling removes instances to meet this maximum.

      Show Advanced Settings > Scaling Policy

      Balanced distribution policy

      Select Balanced Distribution Policy. This policy takes effect only after you select multiple vSwitches.

      VPC

      vpc-2zeghwzptn5zii0w7****

      Select the VPC for the ECS instances in the scaling group.

      vSwitch

      vsw-2ze23nqzig8inprou****

      vsw-2zeet2ksvw7f14ryz****

      vsw-2ze94pjtfuj9vaymf****

      Select the vSwitches to which the ECS instances in the scaling group belong.

      Select multiple vSwitches to enable the balanced distribution policy. This distributes ECS instances across availability zones and improves the success rate of scale-out events.

  3. Create a scaling configuration.

    1. On the Scaling Groups page, find the scaling group that you created and click the ID of the scaling group.

    2. Click the Instance Configuration Source tab.

    3. On the Scaling Configurations tab, click Create Scaling Configuration.

    4. On the Create Scaling Configuration page, configure the parameters and then click Create.

      The following table describes the parameters configured in this tutorial. For unlisted parameters, use the default settings. For more information about how to configure a scaling configuration, see Create a scaling configuration for ECS instances.

      Section

      Parameter

      Example

      Description

      Basic Information

      Scaling Configuration Name

      test

      Enter a name for the scaling configuration. For information about the format requirements, see the on-screen instructions.

      Billing Method

      Spot instance

      Auto Scaling is a free service, but you are charged for the ECS instances it adds. In this tutorial, spot instances are used. For more information, see Billing overview.

      Image and instance

      Instance Configuration Mode

      Specify instance pattern

      Select Specify instance pattern to configure the specifications of the ECS instances.

      Instance Attribute Combination

      2 vCPUs, 4 GiB memory, Enterprise-level

      Set the vCPU and memory requirements for the ECS instances.

      Select Image

      test

      Select an image to deploy the ECS instances.

      For production environments, use a custom image that contains your application.

      Storage

      System Disk

      ESSD, 40 GiB, PL0

      Select a system disk for the ECS instances.

      Network and security group

      Security Group

      sg-bp18kz60mefsicfg****

      Select a security group that you have created. To create a security group, see Create a security group.

      Management settings

      Logon Credentials

      Set later

      Manually set a password for the instances after they are created.

  4. After you create the scaling configuration, follow the on-screen instructions to enable the scaling configuration and the scaling group.

Results

With the minimum instance count set to 100, the scaling group automatically deploys 100 ECS instances after it is enabled, balancing them across the selected availability zones to form the computing cluster. High availability and cost savings are achieved as follows:

  • If an availability zone has insufficient inventory, Auto Scaling automatically tries to deploy ECS instances in the other selected zones, minimizing impact on your application.

  • When a spot instance is reclaimed, the scaling group automatically creates a replacement. It also removes unhealthy instances and replaces them.

Next steps

If insufficient inventory prevents an even distribution of ECS instances, you can rebalance the scaling group to correct the distribution across availability zones. For more information, see Rebalance ECS instances.