This topic describes the billing methods, billable items, and billing examples of Function Compute.
Billing methods
This section describes the billing methods of Function Compute.
Trial quota
Function Compute provides a free trial quota for beginners of Function Compute. An Alibaba Cloud account shares the trial quota with RAM users. The following items provide the details of the trial quota.
GPU: 1 million GB-seconds
vCPU: 500,000 vCPU-seconds
Memory: 2 million GB-seconds
Function invocations: 8 million
The trial quota is valid for three months. You are charged on a pay-as-you-go basis for the excess resource usage.
The trial quota cannot be used to offset the fees of outbound Internet traffic and disk usage. If you do not purchase resource plans, the disk usage exceeding 512 MB and the outbound Internet traffic are billed on the pay-as-you-go basis.
Resource plans
Function Compute provides the following types of resource plans: vCPU resource plans, memory resource plans, GPU resource plans, function invocation plans, and outbound Internet data transfer plans. You can use these resource plans to offset the fees of the corresponding billable items. For more information, see Billable items. The resource plans are preferentially used to offset the fees for resource usage. After the quota in your resource plans is used up, the pay-as-you-go billing method is used.
Resource plans allow you to use resources at more favorable prices. This helps you reduce costs. For more information, see Resource plans.
Pay-as-you-go
You are charged based on the actual amount of computing resources that you use. For more information, see Pay-as-you-go.
Billable items
The billable items of Function Compute include function invocations, resource usage, and outbound Internet traffic.
Function invocations
Function Compute are billed based on the number of function invocations per month. Function invocations are billed in the tired pricing mode.
Tier | Number of invocations | Unit price |
0 | (0, 1 billion] | USD 0.0015 per 10,000 invocations |
1 | (1 billion, 10 billion] | USD 0.0012 per 10,000 invocations |
2 | (10 billion, 50 billion] | USD 0.0008 per 10,000 invocations |
3 | > 50 billion | USD 0.0003 per 10,000 invocations |
Resource usage
Calculation formulas
You can specify vCPUs and memory for function instances based on your business requirements. Fees for the usage of vCPU, memory, and GPU resources are separately calculated. You are charged based on the total resource usage of Function Compute instances per month.
The usage of vCPU resources is billed in the tired pricing mode. The unit price varies based on tiers.
vCPU usage = Number of vCPUs of a function instance × Execution duration (s)
Fee for vCPU usage = Tier 0 vCPU usage × Tier 0 unit price + Tier 1 vCPU usage × Tier 1 unit price + Tier 2 vCPU usage × Tier 2 unit price + Tier 3 vCPU usage × Tier 3 unit price
GPU usage is billed in the tiered pricing mode. The unit prices vary based on tiers.
GPU usage = GPU capacity (GB) of function instances × Execution duration (s)
Fee for GPU usage = Tier 0 GPU usage × Tier 0 unit price + Tier 1 GPU usage × Tier 1 unit price + Tier 2 GPU usage × Tier 2 unit price + Tier 3 GPU usage × Tier 3 unit price
The following formula is used to calculate the memory resource usage fee.
Fee for memory usage = Memory usage of function instances (GB) × Execution duration (s) × Unit price
Concepts
Computing power of instances: The computing power of an instance is proportional to the number of vCPUs and the memory size. To simplify the billing model, Function Compute uses the number of vCPUs or the memory size (GB) of an instance to indicate the computing power of the instance. For example, an instance with 2 vCPUs has twice the computing power of an instance with 1 vCPU, and an instance with 2 GB memory has twice the computing power of an instance with 1 GB memory.
Execution duration: Instances in Function Compute can be used in provisioned or on-demand mode. The execution duration of instances in the preceding two modes varies. For more information, see Instance types and instance modes.
Billing units:
The following units are used for the billing of resource usage.
vCPU-second
Examples of 1 vCPU-second of resource usage: an instance with 1 vCPU runs 1 second, or an instance with 0.5 vCPU runs 2 seconds.
GB-second
Example of 1 GB-second of resource usage: an instance with 1 GB of memory runs 1 second, or an instance with 512 MB of memory runs 2 seconds.
Idle mode
Elastic instances
Elastic instances are classified into active instances and idle instances. Instances that are allocated with vCPUs are active instances. Instances that are not allocated with vCPUs are idle instances.
Active instance
An instance that is processing requests or for which the idle mode is disabled is an active instance.
Idle instance
A provisioned instance for which the idle mode is enabled and not processing requests is an idle instance.
GPU-accelerated instances
GPU-accelerated instances are classified into active instances and idle instances. Instances that are allocated with vCPUs and GPUs are active instances. Instances that are not allocated with vCPUs and GPUs are idle instances.
Active instance
An instance that is processing requests or for which the idle mode is disabled is an active instance.
Idle instances (public preview)
A provisioned instance for which the idle mode is enabled and not processing requests is an idle instance.
If a GPU-accelerated instance is in idle mode, you are charged for the GPU usage based on the unit price of memory.
The idle mode of GPU-accelerated instances is still in public preview. To use the feature, you must use a function that is configured with a full GPU memory. That is, the GPU memory of the instance must be 16 GB (NVIDIA Tesla T4) or 24 GB (NVIDIA Ampere A10). To apply for trial use, click Apply for idle GPU-accelerated instance for public preview.
For more information about the instances in idle mode, see Configure provisioned instances and auto scaling rules.
Unit prices
The following table lists the unit prices of billable items. You are charged based on the specifications that you configure for your function, not the actual amount of consumed resources.
The following table lists the unit prices of GPU usage for different tiers.
Active GPU usage
Tier
GPU usage (GB-second)
Unit price
0
(0, 30 million]
USD 0.000018/GB-second
1
(30 million, 150 million]
USD 0.000015/GB-second
2
(150 million, 600 million]
USD 0.000012/GB-second
3
> 600 million
USD 0.000009/GB-second
Idle GPU usage
When instances are idle, you are charged for the GPU usage based on the unit price of memory. The unit price of the idle instance is USD 0.000002138/GB-second.
For example, a GPU-accelerated instance has 16 GB of GPU memory. When the instance is idle, you are charged for the instance based on the memory usage of 16 GB.
The following table lists the unit prices of vCPU usage for different tiers.
Active vCPU usage
Tier
vCPU usage (vCPU-second)
Unit price
0
(0, 30 million]
USD 0.000015/vCPU-second
1
(30 million, 150 million]
USD 0.000012/vCPU-second
2
(150 million, 1 billion]
USD 0.000009/vCPU-second
3
> 1 billion
USD 0.000006/vCPU-second
Idle vCPU usage: The unit price is USD 0/vCPU-second.
The following table lists the unit prices for other billable items.
Billable item | Unit price |
Memory usage | USD 0.0000015/GB-second |
Disk usage |
Note You are charged based on the disk size that you configure for your function, rather than the actual amount of disk size that your function consumes. |
Outbound Internet traffic
In Function Compute, you are charged based on the total outbound Internet traffic per month. Fee for outbound Internet traffic = (Internet traffic within a function + Traffic for responses to requests + CDN back-to-origin traffic) × Unit traffic price.
Internet traffic within a function: the traffic that is generated when a function sends requests over the Internet.
Traffic for responses to requests: the traffic that is generated when the function returns a response after the function is executed over the Internet.
CDN back-to-origin traffic: the traffic generated when the function in Function Compute is used as the origin of Alibaba Cloud CDN.
Billable item | Unit price |
Outbound Internet traffic | USD 0.117/GB |
Traffic over the internal network is free of charge.
Inbound Internet traffic is free of charge. Examples of inbound traffic: the traffic that is generated when data is returned after a function initiates the request over the Internet, and the traffic that is generated when the client sends a request to invoke a function.
The billing granularity for outbound Internet traffic is KB. The fee of the total amount of outbound Internet traffic per month is rounded to two decimal places.
Billing examples
For example, a function instance is configured with 2 vCPUs, 8,192 MB memory, and 4,096 MB GPU memory. The total number of invocations of the instance is 50 million (within the invocation range at Tier 0), the execution duration is 1 second per invocation, and the outbound Internet traffic is 0. If you want to calculate the monthly fee for invocation of the instance, use the following formula: Total invocation fee = Total number of invocations × Tier 0 unit price.
Fee for function invocation: 50 million × USD 0.0015/10,000 invocations = USD 7.5
Fee for vCPU usage: 30 million vCPU-second × USD 0.000015/vCPU-second + 70 million vCPU-second × USD 0.000012/vCPU-second = USD 1,290
Fee for memory usage: 8,192 MB/1,024 × 50 million invocations × 1 second) × USD 0.0000015/GB-second = USD 600
Fee for GPU usage: 30 million GB-second × USD 0.000018/GB-second + 170 million GB-second × USD 0.000015/GB-second = USD 3,090
Total fee = Fee for function invocation + Fee for vCPU usage + Fee for memory usage + Fee for GPU usage. (USD 7.5 + USD 1,290 + USD 600 + USD 3,090 = USD 4987.5)
Reduce costs by configuring high concurrency for a single instance
Alibaba Cloud Function Compute supports high concurrency on a single instance. You can reduce costs if you reuse resources to process a large number of requests. For more information, see Configure instance concurrency.
For example, you want to process 1 million requests, each of which is processed in 1 second. The following table compares the fee for a single instance that processes a single request and the fee for a single instance that concurrently processes multiple requests. In the following table, the fee for memory usage is calculated.
Mode | Fee for 1 million requests |
A single instance that processes a single request | Fee for memory usage: 1 million × 1 second × USD 0.0000015/GB-second = USD 1.5 |
A single instance that concurrently processes multiple requests | For example, the concurrency for a single instance is 10. Fee for memory usage: 1 million × 1 second/10 × USD 0.0000015/GB-second = USD 0.15. |