Provisioned concurrency can start concurrent instances in advance according to the configuration. SCF will not repossess these instances; instead, it will ensure as much as possible that a corresponding number of concurrent instances are available to process requests.
You can use this feature to set the quota of provisioned concurrent instances for a specified function version, so as to prepare computing resources in advance and reduce the duration for cold start and initialization of runtime environment and business code.
Provisioned concurrency addresses the problem of concurrent instance initialization when requests are received at the version level. After you configure provisioned concurrency for a function version, the following effects will be achieved:
The speed of starting provisioned concurrency is separate from the speed of starting elastically invoked concurrent instances, and starting provisioned concurrency will not occupy the speed of starting 500 concurrent instances per minute at the region level. SCF will adjust the speed of starting provisioned concurrency based on your business, which is 100 concurrent instances per minute by default.
SCF will not repossess provisioned concurrent instances, but concurrent instances may become unavailable due to exiting the process or exceeding the memory limit. Once any instances become unavailable, SCF will repossess them and prepare new concurrent instances to maintain the configuration of provisioned concurrent instances. During this period, the number of actual concurrent instances may be temporarily smaller than the number of provisioned concurrent instances, and fees will not be charged for concurrent instances that are not started. You can view the start status of provisioned concurrency in number of concurrent executions and provisioned concurrency in the function monitoring data.
Provisioned concurrency can be configured only on published versions but not the $LATEST
version. The $LATEST
version is in an editable state, but provisioned concurrency needs to start concurrent instances before requests are received. To ensure the business stability and avoid version inconsistency caused by code and configuration editing, provisioned concurrency can be configured only on published versions. The code and configurations of published versions cannot be changed, so they are suitable for the production environment. For more information, see Version Management.
Provisioned concurrency can help you solve the problem of long initialization of functions, so that they can respond to requests more quickly. It should be noted that provisioned concurrency is not a capability of the concurrency management system, and setting provisioned concurrency will not affect the maximum number of concurrent requests a function can process, which depends entirely on the function's reserved quota or region-level concurrency quota.
Take a function version with a configured memory of 128 MB as an example:
Business Scenario | Average Business Concurrency | Provisioned Concurrency | Function Reserved Quota | Effect |
---|---|---|---|---|
Default condition | 100 concurrent instances | Not configured | Not configured | All concurrent instances need to be initialized when they process requests for the first time. The concurrency quota of the function is affected by other functions under the same account and may be exceeded. |
Function disablement | 100 concurrent instances | Not configured | 0 MB (0 concurrent instances) | The reserved quota is 0, the function is disabled, and all requests will get an overrun error. |
No provisioned concurrency required | 100 concurrent instances | Not configured | 19,200 MB (150 concurrent instances) | All concurrent instances need to be initialized when they process requests for the first time. 150 concurrent instances can be guaranteed, and an overrun error will occur if this limit is exceeded. |
80% provisioning | 100 concurrent instances | 10,240 MB (80 concurrent instances) | 19,200 MB (150 concurrent instances) | 80 concurrent instances don't need to be initialized, and 20 concurrent instances need to be initialized when they are invoked for the first time. 150 concurrent instances can be guaranteed, and an overrun error will occur if this limit is exceeded. |
100% provisioning | 100 concurrent instances | 12,800 MB (100 concurrent instances) | 19,200 MB (150 concurrent instances) | 100 concurrent instances don't need to be initialized, and excessive concurrent instances need to be initialized when they are invoked for the first time. 150 concurrent instances can be guaranteed, and an overrun error will occur if this limit is exceeded. |
Full provisioning | 100 concurrent instances | 19,200 MB (150 concurrent instances) | 19,200 MB (150 concurrent instances) | All concurrent instances don't need to be initialized. 150 concurrent instances can be guaranteed, and an overrun error will occur if this limit is exceeded. |
Overprovisioning | 100 concurrent instances | 25,600 MB (200 concurrent instances) | 19,200 MB (150 concurrent instances) | It is the same as full provisioning except that it incurs additional fees for 50 more provisioned concurrent instances. |
The concurrency management system (region-level concurrency quota and function-level reserved quota) is responsible for processing requests concurrently, while provisioned concurrency is responsible for ensuring that there are concurrent instances available to process requests. The decoupling of the two can implement capabilities such as traffic switch with no initialization process.
The configured provisioned concurrency quota is subject to the account-level quota; in other words, the total provisioned concurrency quotas of all versions of all functions in a region is less than or equal to the concurrency quota at the account level.
For a published function version, you can set a desired number of provisioned concurrent instances.
Note:Provisioned concurrency can be set for a function version only after the version is published.
After the SCF backend adds the provisioned concurrent instances, you can modify the number of concurrent instances as needed.
If you no longer use a provisioned concurrency configuration, you can delete it.
You can set the reserved quota for a function based on the volume of concurrent business requests and configure provisioned concurrency based on the traffic switch needs as instructed below:
Taking the scenario listed in the following table as an example, when a function has a reserved quota of 150 concurrent instances (the function can concurrently process up to 150 requests), you can set 100 provisioned concurrent instances for multiple versions (100 instances are started for each version), so as to switch the traffic with no initialization needed.
Business Scenario | Average Business Concurrency | Provisioned Concurrency | Function Reserved Quota | Effect |
---|---|---|---|---|
100% provisioning | 100 concurrent instances | 12,800 MB (100 concurrent instances) | 19,200 MB (150 concurrent instances) | 100 concurrent instances don't need to be initialized, and excessive concurrent instances need to be initialized when they are invoked for the first time. 150 concurrent instances can be guaranteed, and an overrun error will occur if this limit is exceeded. |
As shown in the figure below, 100 provisioned concurrent instances is configured for both version 4 and version 5, and you can use the traffic grayscale capability to switch the 100 concurrent instances of the business from version 4 to version 5. No matter how the 100 concurrent instances are allocated to versions 4 and 5 according to any proportion, no instances will need to be initialized, thus making it easier for you to publish a version and switch traffic more quickly.
Was this page helpful?