Function Compute offers a variety of billing methods, competitive pricing, and fine-grained resource usage monitoring. These features can help you manage resources for serverless applications and reduce resource costs.

Billing methods for Function Compute

Applications have different types of load and require different resource configurations and levels of scalability. To help you reduce costs in different scenarios, Function Compute offers the subscription and pay-as-you-go billing methods.

Your subscription resource quota is shared by all functions in the same region under your account. Function Compute calculates the resources used by all functions each second and deducts this value from the subscription resource quota. For more information about the subscription and pay-as-you-go billing methods, see Overview.period-cost

Suitable billing methods for applications

Choose a billing method that fits how your applications use resources. For example, assume that you have latency-sensitive online applications in your production environment. To ensure low latency for these applications, you must reserve resources. In this case, you can use the subscription billing method to reduce costs. In contrast, tasks such as test cases and offline data processing are not latency-sensitive but require high throughput. When many tasks must be completed within a specified time frame, a large number of resources may be temporarily required. In this case, you can use the pay-as-you-go billing method. Selecting the most suitable billing method for your applications can help balance resource utilization and costs.

In the Function Compute console, go to the Resource Center page. You can view the usage of resources under the current account, including which areas are stable and which are flexible. You can use this information to allocate subscription and pay-as-you-go resources more efficiently.resource-usage

Removal of idle reserved resources

Function Compute provides fine-grained and multi-dimensional information about resource usage. You can check the reserved resources and the actual resource usage for each function. To reduce costs, you can release idle reserved resources.

In the following figure, the reserved instances allocated to the function have remained idle for a long period of time. In this case, releasing these reserved instances can reduce costs.eg1

Balance resource usage and reduce bursts

To handle a large number of requests when the timeline is flexible, you can limit the number of concurrent instances and use the asynchronous invocation API to process the requests. In the following figure, relatively stable resource demand can be covered by subscription resources to reduce costs. Function Compute internally caches requests in queues and processes those requests at a rate that matches the configured function resource limit. Function Compute also implements load balancing and isolation to prevent functions from affecting each other. To ensure balanced resource usage, set the maximum number of concurrent instances.xufengtiangu

Use resources during off-peak hours

You can run tasks with flexible timelines, such as regression tests, during off-peak hours. For example, you can run regression tests between 21:00 of the current day and 9:00 of the next day. Function Compute provides triggers for you to run your tasks at a scheduled time. In this way, you can use subscription resources to run tasks at a low cost.