Reserved Instance Management
Introduction
FunctionGraph provides on-demand and reserved instances.
- On-demand instances are created and released by FunctionGraph based on actual function usage. When receiving requests to call functions, FunctionGraph automatically allocates execution resources to the requests.
- Reserved instances can be created and released by you as required. After you create reserved instances for a function, FunctionGraph preferentially forwards requests to the reserved instances. If the number of requests exceeds the processing capability of the reserved instances, FunctionGraph will forward the excessive requests to on-demand instances and automatically allocates execution resources to these requests.
After reserved instances are created for a function, the code, dependencies, and initializer of the function are automatically loaded. Reserved instances are always alive in the execution environment, eliminating the influence of cold starts on your services. (Do not execute one-time services using the initializer of reserved instances.)
You can configure a fixed number of reserved instances or scheduled, metric, and intelligent recommendation policies.
By default, you do not have permission to use the metric and intelligent recommendation policies. To use them, submit a service ticket.
Configuring a Fixed Number of Reserved Instances
Ensure that the function for which you want to create reserved instances already exists on the FunctionGraph console.
- Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
- Click the target function to go to the details page.
- Choose Configuration > Concurrency, and click Add.
Figure 1 Clicking Add
- Set parameters by referring to Table 1.
You can create a specified number of reserved instances for a function version or alias. This number cannot exceed the maximum number of requests per instance or the maximum number of instances per function.Figure 2 Basic settings
Table 1 Basic settings Parameter
Description
Function Name
Name of the current function.
Type
Select Version or Aliases.
Version
Set this parameter when you select Version for Type.
Alias
Set this parameter when you select Aliases for Type.
Min. Instances
Minimum number of instances. Max.: 1000. FunctionGraph reserves the specified number of instances for the function. These instances will always run unless you change Min. Instances to 0.
Idle Mode
This mode saves costs as CPU resources are not used when reserved instances are not invoked.
- Reserved instances cannot be configured for both a function alias and the corresponding version. For example, if the alias of the latest version is 1.0 and reserved instances have been configured for this version, no more instances can be configured for alias 1.0.
- After the idle mode is enabled, reserved instances are initialized and the mode change needs some time to take effect. You will still be billed at the price of reserved instances for non-idle mode in this period.
- If the function concurrency is greater than the number of reserved instances, the excess requests will be allocated to on-demand instances, which involve a cold start.
- Click OK. The new policy is displayed in the reserved instance policy list.
Figure 3 Policy list
Configuring a Scheduled Scaling Policy
Configure the number of reserved instances that will run in a specified period and a cron expression. During this period, FunctionGraph adjusts the number of reserved instances based on the cron expression. When the period expires, the fixed number of instances will be reserved.
- Configure the basic settings by referring to Table 1, and then click Add Policy.
Figure 4 Clicking Add Policy
- Set parameters by referring to Table 2.
Figure 5 Adding a policy
Table 2 Scheduled scaling policy parameters Parameter
Description
Policy Name
Policy name.
Cron Expression (UTC)
Set this parameter by referring to Cron Expressions for a Function Timer Trigger.
Validity
Local time when the cron expression is effective.
The scheduled scaling policy is effective only during this validity period. In other time, the Min. Instances in the basic settings is used.
Min. Instances
The number of reserved instances to be created when the policy is effective.
Set a number that meets your service requirements.
NOTE:The number must be greater than or equal to the Min. Instances in the basic settings.
- Click OK. The new policy is displayed in the reserved instance policy list.
Figure 6 Policy list
- To modify the reserved instance policy, click Edit in the Operation column. Then modify or add scheduled scaling policies.
- To delete a reserved instance policy under a function version or alias, click Delete in the Operation column.
- To view concurrent instances, click a quantifier in the reserved instance policy list, and click a scheduled scaling policy name.
Multiple scheduled policies can be configured. For example, the number of reserved instances at 08:00 and 21:00 is updated to 100 and 10 respectively.
Configuring a Metric Scaling Policy
You can dynamically adjust the number of reserved instances based on service metrics (currently, only the number of concurrent users is supported). When configuring metric policies, you need to configure an agency that has permission to query AOM metrics and query and configure functions.
- Configure the basic settings by referring to Table 1, and then click Add Policy.
Figure 7 Adding a policy
- Set parameters by referring to Table 3.
Figure 8 Configuring a metric policy
Table 3 Metric policy parameters Parameter
Description
Policy Name
Policy name.
Used Instances (%)
The value ranges from 1 to 99, that is, the percentage of actually used reserved instances to the total number of reserved instances of the function. If the actual value is higher than the threshold, FunctionGraph gradually reduces the number of reserved instances. If the actual value is lower than the threshold, FunctionGraph directly creates the corresponding number of reserved instances every minute. (The metric is also generated every minute. Therefore, the adjustment will be delayed for 1 to 2 minutes.)
Reserved Instances
The number of reserved instances to be created when the threshold is not reached.
It specifies the latest number of reserved instances based on the metric policy. For example, if only one reserved instance needs to be created based on the policy and the minimum number of reserved instances is set to 5, five reserved instances will be created.
NOTE:The number must be greater than or equal to the Min. Instances in the basic settings.
Table 4 Configuring agency permissions Service
Common Permission
Fine-Grained Permission
FunctionGraph
FunctionGraph ReadOnlyAccess
functiongraph:function:getConfig
- Click OK. The new policy is displayed in the reserved instance policy list.
Figure 9 Policy list
- To modify the reserved instance policy, click Edit in the Operation column. Then modify or add scheduled scaling policies.
- To delete a reserved instance policy under a function version or alias, click Delete in the Operation column.
- To view concurrent instances, click a quantifier in the reserved instance policy list, and click a scheduled scaling policy name.
Scheduled policies and metric policies can be added together. When both policies are added, the minimum number of reserved instances for one of the policy types cannot be less than the latest number of reserved instances for the other policy type. For example, at 08:59, 9 reserved instances are updated by the metric policy, and 5 instances are configured for a scheduled policy at 10:00. Therefore, 9 reserved instances are updated at 10:00. If the next scheduled policy takes effect at 11:00, at least 5 reserved instances will be updated during10:00 and 11:00.
Configuring an Intelligent Recommendation Policy
Intelligent recommendation policies are based on feature profiling and load prediction technologies, dynamically adjusting reserved instances for peak and off-peak demands.
Intelligent recommendation policies are available in three options: high performance, balance, and low cost. The system dynamically adjusts the number of reserved instances based on load prediction to adapt to the peak and off-peak loads. The cost and performance of reserved instances are displayed. (Intelligent recommendation policies cannot coexist with other types of policies. A function version or alias can have only one such policy.)
- Click Add Policy, as shown in the following figure.
Figure 10 Clicking Add Policy
- Select Intelligent recommendation, and select any of High performance, Balance, and Low cost while referring to the performance and cost trends.
Figure 11 Intelligent recommendation
- Click OK. The new policy is displayed in the reserved instance policy list.
Figure 12 Reserved Instance Policies
- To view and modify a reserved instance policy, click Edit in the Operation column.
- To delete a reserved instance policy under a function version or alias, click Delete in the Operation column.
- Reserved instances are executed with the intelligent recommendation policy. To view the reserved instance costs and performance, click a quantifier in the policy list, and click a policy name.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.