All Products
Search
Document Center

Use reserved instances

Last Updated: Apr 02, 2021

If you run long-term online applications, we recommend that you use reserved instances to offset the bills of elastic container instances. This topic describes how to use reserved instances to offset the bills of long-term elastic container instances.

Purchase reserved instances

Reserved instances automatically match Elastic Compute Service (ECS) instances (excluding preemptible instances) in your account to provide a billing discount. If you use an ECS instance type to create an elastic container instance, you can use reserved instances to offset the bills of the elastic container instance. For more information, see Reserved instance overview.

You can use reserved instances to offset the bills only of elastic container instances created by specifying ECS instance types. Before you purchase a reserved instance, take note of the following items:

  • Only some ECS instance types can be used to create elastic container instances. Make sure that the selected ECS instance type can suit your business needs. For more information, see Create an elastic container instance of the specified ECS instance type.

  • Reserved instances can be applied only to elastic container instances that meet the matching rules. Make sure that your elastic container instances can be matched to the reserved instances

    Note

    After you purchase reserved instances, you make commitments to use pay-as-you-go elastic container instances for a certain period of time. Reserved instances provide significant discounts compared with pay-as-you-go pricing. After a reserved instance is matched, it checks for eligible pay-as-you-go bills on an hourly basis and deducts fees based on its computing power. For more information, see Match between reserved instances and pay-as-you-go instances.

You can purchase and manage reserved instances on the Reserved Instances page in the ECS console. For more information, see Purchase reserved instances.

  • If you want to optimize the cost of existing elastic container instances, you can find elastic container instances created by using specific ECS instance types and purchase reserved instances based on the ECS instance types.

  • If you have no existing elastic container instances, select ECS instance types based on your business needs and purchase suitable reserved instances. You can create elastic container instances by using the selected ECS instance types.

Create elastic container instances

If you have existing reserved instances, you must specify the corresponding ECS instance types to create elastic container instances. Otherwise, the reserved instances cannot be used to offset the bills.

Kubernetes

If you have purchased reserved instances of ecs.c5.large, you must specify the ecs.c5.large ECS instance type when you create elastic container instances.

Note

If you are using a Container Service for Kubernetes (ACK) or serverless Kubernetes (ASK) cluster and you have purchased a zonal reserved instance, make sure that the reserved instance and the cluster reside within the same zone. Otherwise, the reserved instances cannot be used to offset the bills. If the cluster and the reserved zones are located in different zones, you can change the zonal reserved instance into a regional reserved instance. For more information, see Modify a reserved instance.

You can specify an ECS instance type by adding annotations to the YAML file in the spec > template > metadata section. Example:

apiVersion: apps/v1 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
  name: nginx-deployment-basic
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
      annotations:
        k8s.aliyun.com/eci-use-specs : ecs.c5.large  # Replace the value with the ECS instance type that matches the reserved instance.
    spec:
    #  nodeSelector:
    #    env: test-team
      containers:
      - name: nginx
        image: nginx:1.7.9 # replace it with your exactly <image_name:tags>
        ports:
        - containerPort: 80

API operation

If you have ecs.c5.large reserved instances, you must use the InstanceType parameter to specify the ecs.c5.large ECS instance type when you call the CreateContainerGroup operation to create an elastic container instance. The following table describes the InstanceType parameter. For more information, see CreateContainerGroup.

Parameter

Type

Required

Example

Description

InstanceType

String

No

ecs.c5.xlarge

The ECS instance type that can match the reserved instance. You can specify up to five ECS instance types at a time and separate the ECS instance types with commas (,). Example: ecs.c5.xlarge,ecs.g5.xlarge.

View deduction information of a reserved instance

You can view thebilling details of elastic container instances and reserved instances in the Billing Management console.

Notice

In scenarios where multiple zones are specified to create elastic container instances, the created elastic container instances may be located in multiple zones. If you find that a reserved instance does not deduct the bills of an elastic container instance, check whether the reserved instance and the elastic container instance are within the same zone. If the reserved instance and the elastic container instance are located in different zones, you can change the zonal reserved instance into a regional reserved instance. For more information, see Modify a reserved instance.

  • View bills of elastic container instances

    On the Spending Summary page, select the Details tab. You can view the consumption details by elastic container instance. For the fees of elastic container instances that are offset by reserved instances, no bills are generated.

  • View the bill of reserved instances

    On the Manage Reserved Instances page, you can view the deduction details of the reserved instances.

    The usage details of the reserved instances show the elastic container instances whose fees are deducted by the reserved instances during every billing hour. The deduction duration is calculated by using the following formula: Computing power × Number of hours. Reserved instances are deducted by computing power. One unit of computing power is equivalent to one vCPU.