The reserved instances feature is an exclusive feature of serverless Kubernetes (ASK) Knative. If you want to reduce costs by using Knative and avoid cold starts at the same time, we recommend that you use reserved instances.
Benefits
By default, the open source version of Knative scales the number of instances to zero during off-peak hours. This reduces the costs on instances. The costs are reduced by scaling the number of instances to zero. However, a cold start with a latency occurs the next time you start an application. To create a new instance, the system must first allocate infrastructure resources by using the Kubernetes scheduler. The system must also pull the application image and start up the application. The image size of an application and the time required to start up an application vary based on the requirements of developers and services. Common platforms do not have control over the image size and startup time.

How reserved instances work
ASK Knative uses reserved instances to replace compute-optimized instances during off-peak hours. When ASK Knative receives a request, it uses the reserved instances to process the request and starts to create compute-optimized instances. After the compute-optimized instances are created, all new requests are forwarded to these instances. Reserved instances are released after they process all requests that are sent to them. This seamless switchover mechanism reduces the costs on instances and the latency caused by cold starts.
Reserved instance types
Alibaba Cloud Elastic Container Instance provides burstable instances. Burstable instances use CPU credits to ensure computing performance. The instances apply to scenarios where the CPU usage is low but bursts in CPU usage occur on occasion. A burstable instance can accumulate CPU credits. If a burstable instance fails to handle a heavy workload, it consumes CPU credits to improve computing performance. This mechanism does not affect the environment or applications running on the instance. Compared with other types of instances, a burstable instance provides a more flexible and cost-effective way to use CPU resources. The CPU credit mechanism allows you to minimize the consumption of resources during off-peak hours and scale out resources during peak hours. This reduces the cost of resources.
knative.aliyun.com/reserve-instance-eci-use-specs
annotation. You can configure instance types in the following two ways:
- Specify the types of elastic container instances. In the following example, ecs.t6-c1m1.large
and ecs.t5-lc1m2.small are specified.
apiVersion: serving.knative.dev/v1 kind: Service metadata: name: hello-spec-1 spec: template: metadata: annotations: knative.aliyun.com/reserve-instance-eci-use-specs: "ecs.t6-c1m1.large,ecs.t5-lc1m2.small" spec: containers: - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
- Specify the minimum CPU cores and memory. ASK Knative automatically searches for instance
types that meet the requirements and uses the five lowest-priced instance types to
create instances. In the following example,
1-2Gi
indicates 1 CPU core and 2 GB of memory.apiVersion: serving.knative.dev/v1 kind: Service metadata: name: hello-spec-2 spec: template: metadata: annotations: knative.aliyun.com/reserve-instance-eci-use-specs: "1-2Gi" spec: containers: - image: registry.cn-hangzhou.aliyuncs.com/knative-sample/helloworld-go:160e4dc8
Knative creates elastic container instances based on a list of elastic container instance types. The instance types are listed in sequential order. If an instance type is unavailable, the next instance type in the list is used.