The total cost of Function Compute consists of cost for total number of invocations, cost for the execution duration, possible Internet downstream traffic fee, and possible CDN back-to-source traffic fee. You can enjoy free Function Compute services of a certain amount. In addition, you can use the Function Compute price calculator to calculate the specific cost of the function.
Note: Starting from September 19, 2019, the metering and billing of Function Compute will be upgraded to version 2.0. The new metering and billing model maintains forward compatibility and provides richer functions, enabling Function Compute to maintain excellent cost performance in various scenarios. For the differences between the old and new metering and billing methods, see related documents.
The invocation count is the total number of invocations to all of your functions, aggregated by hour.
Unit Price: 0.2 USD/million times.
Execution duration = Billing duration * Unit price
Function Compute offers reserved and pay-as-you-go instances that have different methods of calculating billing duration. Reserved instances are allocated and released by users and billed by runtime. Reserved instances allow you to prefetch functions to completely eliminate the impact of cold start on latency. As shown in the following figure, billing starts after the system starts the reserved instance by invoking the reserved instance API. Before you call the operation to release an instance, make sure that no new requests are sent to the instance. The billing stops as the instance is released. The reserved instances are billed in seconds. If the subscription time is less than one minute, the value is rounded up to one minute. For example, if the running duration of a reserved instance is 51 seconds, the instance is billed at 1 minute. If the runtime is 61 seconds, and the billing is still 61 seconds.
Function Compute allocates and releases pay-as-you-go instances billed in terms of the duration of the request execution. As shown in the following figure, a pay-as-you-go instance runs multiple requests simultaneously, starting when the first request arrives at the instance and ending when the last request is executed. A pay-as-you-go instance is billed in 100 milliseconds. For example, if the execution duration of a function instance is 1010 milliseconds, the duration is measured as 1100 milliseconds.
Function Compute supports two resource consumption modes: subscription and pay-as-you-go. Subscription allows you to estimate the resource demands of applications and then use them after purchasing a specified number of coupons. Pay-as-you-go means that you only pay for the resources that you have used. The unit price of subscription resources is much lower than that of pay-as-you-go resources. You can purchase the coupons in subscription mode to offset the resources that are actually used to lower your cost.
Function Compute uses Capacity units (CU-Second) to quantify the computing power of function instances. For more information about the computing power of reserved and pay-as-you-go instances, see instance types. The price unit of the execution duration is USD/CU-second, which indicates the cost of running an instance with one CU of computing power per second.
- Subscription-based resource consumption coupons are used to offset charges, but do not provide real instance resources. Both Reserved and pay-as-you-go instances can be used in subscription mode.
- If Function Compute fails to deliver services as subscribed due to insufficient underlying computing resources, the fees incurred during this period will be compensated. We recommend that you reserve instances first and then use reserved instances to offset the resource consumption.
- The compute units used by reserved and pay-as-you-go instances are different. For more information, see instance types and unit prices.
- For the best practices of using subscription to optimize costs, see related documents .
Reserved instance types and pricing
|Reserved Instance Type||Computing Power (CU)||Pre-payment (Subscription) Monthly Fee (USD)||Post-paid Fee per Second (USD)|
|0.67 vCPUs and 1024 MB memory||1.||12.16||0.000016384|
|1 vCPU, 1536 MB memory||1.5||18.24||0.000024576|
|1.33 vCPUs and 2048 MB memory||2||24.32||0.000032768|
|1.67 VCPUs, 2560 MB memory||2.5||30.4||0.00004096|
|2 vCPUs and 3072 MB memory||3||36.48||0.000049152|
Pay-as-you-go instance types and pricing
Pay-as-you-go instances are allocated a minimum memory size of 128 MB and a maximum memory size of 3072 MB. The memory capacity is 128 MB, 192 MB, 256 MB,……, 2944 MB, 3008 MB, and 3072 MB, with 64 MB as a difference. The computing power of the instance is proportional to the memory size. The computing power of 1 GB memory instance is 1 CU, and that of 1.5 GB memory instance is 1.5 CU, and so on. The monthly fee for the subscription of a 1 CU instance is 12.16 USD. A 1 CU pay-as-you-go instance fee is 0.000016384 USD per second.
Note: Pay-as-you-go instances are billed only when your function code is actually executed. Therefore:
- Requests whose response status code are 4XX or 5XX due to errors such as parameter, permission, and service errors are not billed.
- Requests whose response status code are 200 but errors occur during function execution are billed.
- The status code of the HTTP Trigger request can be configured in the function. The request is charged based on
x-Fc-Error-Typein the response header. If its value is
FCCommonError, it indicates that the function is not executed and the request is not billed. If another value occurs, the request is billed.
Function Compute calculates the total computing power of all function instances under an account and the credit of consumed resources by second.
As shown in the preceding figure, a user can use 30 CU-Second of reserved resources in a subscription manner. This means that the user can use 30 CU-Second of reserved resources per second. In the first second, instance 1 consumed 40 * 0.5=20 CU-Second; In the next second, instances 1 and 2 consumed 40 * 0.75+20 * 1=50 CU-Second resources in total. In the third second, instances 2 and 3 consumed 20 * 1+10 * 1=30 CU-Second resources. In the fourth second, instance 2 consumed 20 * 1=20 CU-Second resources. The following table shows the user’s payment:
|Time Window||Actual Resource Consumption (CU-Second)||Pre-payment Amount (CU-Second)||Pay-as-you-go Quota (CU-Second)|
|The first second||20||30||0|
|The third second||30||30||0|
|The 4th second||20||30||0|
For more information about how to use reserved instances (subscription), see related documents .
Internet traffic fees are incurred only when you use Function Compute to transfer data out of the Internet (outbound traffic). The Internet downstream traffic includes two parts:
- Invocation of a function over the Internet and the data returned by the function
- Data transmission to the Internet
The accumulated Internet traffic in the preceding two parts is calculated by using the pay-by-traffic billing method. Currently, the unit price is 0.117/GB USD. For more information, see ECS bandwidth billing .
For example, a user invoked a function through the Internet and uploaded a 10 MB file to a public server through the function. That is, 10 MB of downstream traffic was generated during the execution of the function. The Internet traffic generated is 10MB +200 B, indicating successful execution (a JSON string with a size of 200 bytes), and the cost 0.117 * (10.0 / 1024 + 200.0 / 1024 / 1024 / 1024) = 0.00114 USD.
- Traffic generated by access to the Alibaba Cloud VPC is not Internet traffic and therefore will not be billed.
- The upstream traffic generated by uploading data to functions over the Internet does not incur any charges.
- If you use API Gateway to invoke a function and API Gateway is in the same region as Function Compute, the function is invoked within the VPC and no traffic cost is incurred.
- Cross-region function invocations belong to Internet access.
If you set content delivery network (CDN) back-to-source processing to Function Compute, you need to pay for the traffic of transfer over the back-to-source network.
Internet traffic fee in China: 0.117 USD/GB (for large customers with relatively large traffic, please open a ticket for quotation).
If you use other Alibaba cloud services in your functions, you will be charged with additional fees. For example, you use a function to write data to Object Storage Service (OSS), or enable Log Service to store logs. For more information, see OSS metering and billing items , Log Service billing methods, and other documents.
Free monthly quotas
Your Alibaba Cloud account and RAM user account share the free monthly quotas of executions and execution duration. Free quotas are not accumulated in each month, but will be reset and calculated again at the start of each calendar month.
Number of invocations: The first million function invocations per month are free of charge.
Execution time : The first 400,000 (CU-Second) of each month is free of charge.