Function Compute provides two types of instances: performance instances and flexible instances. This topic compares the two types of instances and describes the specifications, usage notes, usage modes, and billing methods of the two types of instances.
- Flexible instance: the basic instance type of Function Compute. Flexible instances have specifications lower than those of performance instances. Flexible instances cannot be used to execute offline tasks that last for a long time or smoothly migrate large applications to Function Compute.
- Performance instance: an instance type that has higher specifications. Function Compute provides multiple specifications with more resources allowed for performance instances. Therefore, performance instances are applicable to more scenarios than flexible instances.
For more information, see Instance specifications.
You can specify the instance type and specifications when you create or modify a function. For more information, see Create a function and Modify a function. If you select a performance instance, your functions are executed in an instance with stronger computing power.
- Performance instance
The following table describes the specifications provided by Function Compute for performance instances. You can select instance specifications based on your business requirements.
Number of CPU cores Memory size (GB) Package size (MB) Execution duration of functions (s) Disk size (GB) Bandwidth (Gbit/s) 2 4 500 7200 10 1 4 8 500 7200 10 1.5 8 16 500 7200 10 2.5
- Flexible instance
Memory size (MB) Maximum package size (MB) Maximum execution duration of functions (s) Disk size (MB) 128~3072 50 900 512
- Prerequisites for using performance instances
You must create a virtual private cloud (VPC) before you can use performance instances. To create a VPC, contact the technical support.
- Limits on switching the instance type
If you switch the instance type without risk assessment, function errors may occur. To prevent such errors, Function Compute allows you to switch the instance type only from the flexible instance to the performance instance when you modify a function.
- Combination of instance types for reduced cold start time
Compared with flexible instances, performance instances scale out slowly and have inferior flexible scalability. If long execution duration, a large amount of CPU resources, fast cold start, and cost efficiency are required, you can use a combination of performance instances and other features, such as multiple requests, provisioned instances, and subscriptions.
- Performance instances: provide long execution duration of functions, large package size, and specific CPU resources. For more information, see Instance specifications.
- Multiple requests: use the same instance based on well-defined CPU and memory capacity for multiple requests to reduce costs. For more information, see Concurrent requests in a single instance.
- Provisioned instances: reduce the cold start time. For more information, see Overview.
- Subscriptions: offset the fees for instances that are provisioned for a long period of time. This billing method reduces costs by 70%. For more information, see Overview.
- Cold start feedback for performance instances
Issues related to cold start may occur in scenarios in which scale-out is required, such as sparse invocations and increasing loads. A cold start takes hundreds of milliseconds on flexible instances, whereas it takes dozens of seconds to minutes on performance instances. To prevent slow response speed caused by long cold start time, Function Compute returns the status of performance instances to you within a short period of time.
Instance usage modes
Performance instances and flexible instances support the following usage modes:
- On-demand mode
In on-demand mode, Function Compute automatically allocates and releases instances for functions. In this mode, the execution duration starts from the time when a request is sent to execute a function and ends when the request is executed. An on-demand instance can process a single request at a time or concurrently process multiple requests. For more information, see Concurrent requests in a single instance.
Notice In pay-as-you-go mode, the execution duration of functions by on-demand performance instances and that by on-demand flexible instances are billed at different granularities.
- Execution duration of functions by a single instance that processes a single request
at a time
When an on-demand instance processes a single request, the execution duration is calculated from the time when the request arrives at the instance to the time when the request is executed.
- Execution duration of functions by a single instance that concurrently processes multiple
When an on-demand instance concurrently processes multiple requests, the execution duration is calculated from the time when the first request arrives at the instance to the time when the last request is executed. You can reduce costs by reusing resources to concurrently process multiple requests.
- Flexible instances: The billing granularity is 1 millisecond.
- Performance instances: The billing granularity is 1 millisecond. If the execution duration is less than 1 minute, it is billed as 1 minute. For example, if the execution duration of functions by an on-demand performance instance is 51 milliseconds, the execution duration is billed as 1 minute. If the execution duration is 60,001 milliseconds, it is billed as 60,001 milliseconds.
- Execution duration of functions by a single instance that processes a single request at a time
- Provisioned mode
In provisioned mode, you allocate, release, and manage instances. For more information, see Overview. In this mode, the execution duration starts from the time when Function Compute starts a provisioned instance and ends when you release the instance. Therefore, regardless of whether the provisioned instance executes requests, you are charged for the instance until you release the instance.Notice In pay-as-you-go mode, the execution duration of functions by provisioned performance instances and that by provisioned flexible instances are both billed at the granularity of 1 second. If the execution duration is less than 1 minute, it is billed as 1 minute. For example, if the execution duration of functions by a provisioned instance is 51 seconds, the execution duration is billed as 1 minute. If the execution duration is 61 seconds, it is billed as 61 seconds.
For more information about the billing methods, see the following topics:
- For more information about how to use SDKs to configure and modify the instance for a function, see Configure the instance type.