All Products
Search
Document Center

Billing methods

Last Updated: Apr 26, 2020

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

Billing duration

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.

provision-billing

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.

按量实例计量

Unit price

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.

Note:

  1. 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.
  2. 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.
  3. The compute units used by reserved and pay-as-you-go instances are different. For more information, see instance types and unit prices.
  4. For the best practices of using subscription to optimize costs, see related documents .

Reserved instance types and pricing

Reserved Instance TypeComputing Power (CU)Pre-payment (Subscription) Monthly Fee (USD)Post-paid Fee per Second (USD)
0.67 vCPUs and 1024 MB memory1.12.160.000016384
1 vCPU, 1536 MB memory1.518.240.000024576
1.33 vCPUs and 2048 MB memory224.320.000032768
1.67 VCPUs, 2560 MB memory2.530.40.00004096
2 vCPUs and 3072 MB memory336.480.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:

  1. Requests whose response status code are 4XX or 5XX due to errors such as parameter, permission, and service errors are not billed.
  2. Requests whose response status code are 200 but errors occur during function execution are billed.
  3. The status code of the HTTP Trigger request can be configured in the function. The request is charged based on x-Fc-Error-Type in 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.

Subscription deduction

Function Compute calculates the total computing power of all function instances under an account and the credit of consumed resources by second.

pre-paid-discount

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 second20300
Second503020
The third second30300
The 4th second20300

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:

  1. Invocation of a function over the Internet and the data returned by the function
  2. 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.

Note:

  1. Traffic generated by access to the Alibaba Cloud VPC is not Internet traffic and therefore will not be billed.
  2. The upstream traffic generated by uploading data to functions over the Internet does not incur any charges.
  3. 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.
  4. 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.