Auto scaling

Updated at:

EAS provides auto scaling for your services. Scaling policies and resource planning keep a service stable under peak load and scale it down on demand during off-peak periods. Together they balance performance against cost.

Select a scaling policy

Scaling policies fall into two types based on what triggers them: horizontal auto-scaling is triggered by metrics, and scheduled auto-scaling is triggered by a schedule. You can enable both at the same time — scheduled auto-scaling covers predictable periodic peaks, and horizontal auto-scaling covers unpredictable burst traffic. The following table lists recommended configurations based on how peaks occur.

Peak pattern

Recommended configuration

Description

Peak and off-peak periods occur at fixed times and can be scheduled in advance

Scheduled auto scaling

Adjusts the number of replicas on a schedule. Suitable for daytime peaks and events with fixed schedules.

Peaks occur at unpredictable times

Horizontal auto scaling

Automatically adjusts the number of replicas based on metrics such as QPS, CPU, and GPU.

In addition to peaks at fixed times, unpredictable burst traffic also occurs

Enable both scheduled auto-scaling and horizontal auto-scaling

Scheduled scaling handles predictable baseline changes, and horizontal scaling responds to burst traffic. For the combined behavior, see Combination with horizontal auto scaling.

Plan service resources

Whether a scale-out takes effect depends on whether resources are available for the new replicas. Resource planning starts with the resource types available to your service, then secures the resource supply for scale-out based on the service's current resource configuration. When multiple services need to share resources, a virtual resource group schedules them together and improves overall resource utilization.

Resources available to a service

EAS provides resource types such as public resources, dedicated resource groups, resource quotas, and virtual resource groups. Each type differs in capacity stability, cost, and how you use it, so choose the one that fits your workload.

Resource type

Key features

Scenarios

Public resources

Used on a pay-as-you-go basis with no upfront purchase, but may be out of stock during peak periods

Development and testing, workloads whose resource usage you cannot determine in advance, or capacity that you need to add on a pay-as-you-go basis

Dedicated resource group

Uses machines that you have already purchased, with exclusive resources and stable capacity

Production workloads that require resource isolation and performance stability

Resource quota

Resource capacity purchased in advance and scheduled within the quota

Production workloads that need exclusive resources or specific high-performance hardware

Virtual resource group

Combines multiple existing resource types, with unified scheduling and configurable priorities

A single service mixes multiple resource types, or multiple services share resources

Resource assurance for scale-out

When a service scales out, it first uses the resources in its current configuration. If that capacity is not enough, you can increase your own resource capacity or add other resources through mechanisms such as the elastic resource pool. Your own capacity is more stable. The elastic resource pool better suits periodic peaks and helps reduce the cost of holding resources long term.

Resources the service currently uses

Scale-out assurance

Cost control

Public resources

No capacity needs to be held in advance, and replicas are created on a pay-as-you-go basis. Configure multiple specifications to handle resources being out of stock; they are tried automatically in sequence.

Use preemptible instances to reduce costs. Preemptible instances may be reclaimed, so configure regular specifications as well.

Dedicated resource group

Purchase more dedicated machines, or supplement with public resources through the elastic resource pool. The elastic resource pool supports multiple specifications.

Hold dedicated resources for your baseline rather than your peak to reduce long-term holding costs. You can combine them with preemptible instances.

Resource quota

Increase the quota capacity, or supplement with public resources through the elastic resource pool.

Use off-peak resources to reduce costs. However, off-peak resources may be reclaimed.

Virtual resource group

Add resources within the group, or supplement with public resources through the elastic resource pool.

Set priorities by cost so that lower-cost resources are scheduled first.

For how to use each resource type, see the following references:

Virtual resource group: share resources and improve utilization

  • Combine multiple resource types: Virtual resource groups can combine public resources, dedicated resource groups, and resource quotas into a single logical resource pool. They support unified deployment, unified scheduling, and priority settings across resource types. A single service can use a virtual resource group to mix multiple resource types.

  • Share resources across staggered peaks: Multiple services can share the same virtual resource group. When the peak periods of these services differ, the resources that an off-peak service releases after scaling in become available to services at their peak. This avoids each service reserving resources separately for its own peak and improves overall resource utilization.

  • Group resources first, overflow when insufficient: When used together with the elastic resource pool, scheduling first draws on the resources within the group. When those resources are not enough, workloads overflow to public resources.

Relationships between configurations

Scaling policies and resource-side measures each have their own scope. The following three relationships are the ones most often misused.

  • Elastic resource pool and auto scaling

    The two work together. Auto scaling decides whether the replica count increases. The elastic resource pool decides whether new replicas can be placed on public resources when your own resources are not enough. Enabling only the elastic resource pool does not change the replica count in response to metrics, so you still need to configure horizontal or scheduled auto-scaling.

  • Elastic resource pool and virtual resource group

    The two operate at different levels. The elastic resource pool is a service-level policy that applies to EAS resource groups and resource quotas, and its only overflow target is public resources. A virtual resource group is a type of EAS resource group that allocates multiple resource types at the resource group level and supports scheduling priorities. The two do not conflict and can be used together.

  • Virtual resource group and dedicated resource group

    Both are EAS resource groups. A dedicated resource group uses the instances that you have already purchased, and its capacity is determined by those instances. A virtual resource group is made up of the resources available to you and schedules work across multiple resource types. Use a dedicated resource group when capacity is stable and predictable, and a virtual resource group when you need to balance capacity across resource types.