Billing Mode

Last updated: 2021-06-02 15:03:30

    Billing Mode

    You can estimate your SCF usage and calculate the corresponding fees by using the SCF Price Calculator. For more information on SCF billing, please see Billing Mode, Pricing, and Notes on Overdue Payment.

    SCF is pay-as-you-go hourly in USD based on your actual usage. An SCF bill consists of the following four parts (each part is billed according to its statistics and calculation method, and the fees are accurate to two decimal places in USD).

    • Resource usage fees
    • Invocation fees
    • Public network outbound traffic fees
    • Idle provisioned concurrency fees

    For the unit prices of resource usage, invocations, public network outbound traffic, and idle provisioned concurrency, please see Pricing. Here, the public network outbound traffic is calculated in GB. For more information, please see the "Bill-by-traffic" section in Public Network Billing.

    Billing Principles

    SCF fees will be incurred by the actual loading and execution of the function code. If the function code is not actually executed, no fees will be incurred unless provisioned concurrency is configured. Below is an example:

    Scenario Function Execution Status Calculated Billed
    A request error occurs due to an incorrect parameter, incorrect function name, or non-existent function. Not executed No No
    An error occurs due to function execution timeout or function execution memory overrun. Executed Yes Yes
    An error occurs due to a function code problem. Executed Yes Yes
    A request error occurs due to concurrency overrun. Not executed No No

    Resource Usage Fees

    Resource usage fees = (resource usage - free tier) * resource usage unit price

    Resource usage in GBs

    Resource usage = configured function memory size * execution duration

    Resource usage is calculated by multiplying the configured function memory size by the billable function execution duration. Here, the configured memory size is in GB, and the billable duration is converted from milliseconds to seconds. Therefore, the resource usage is in GBs (GB-second).

    For example, if a function with 256 MB memory configured is executed for 1,760 ms, then the billable duration is 1,760 ms, and the resource usage of this function execution will be (256 / 1024) * (1760 / 1000) = 0.44 GBs.

    Resource usage will be calculated for each function execution and aggregated in each hour as the hourly resource usage.

    Note:

    • Currently, SCF resource usage is calculated by multiplying the configured function memory size by the actually triggered execution duration of the function. Compared with the billing method of 100-ms upward aggregation, this billing method calculates lower overall resource usage and incurs fewer fees. For more information, please see Billing Example.
    • Due to issues such as the uncertainty of computing resources where SCF runs, specific actions in the code, and relevant network communications, the execution duration of the same function code may vary slightly when the code is triggered at different times.

    Invocation Fees

    Invocation fees = (number of function invocations - free tier) * invocation unit price

    Each function triggering and execution will be calculated as an invocation and aggregated in each hour as the hourly invocation volume. Fees will be charged per 10,000 invocations.

    Public Network Outbound Traffic Fees

    Public network outbound traffic fees = public outbound traffic * traffic unit price

    Outbound traffic will be generated when resources are accessed over the public network in a function, such as uploading a file to an external storage space:

    • When the code writes files to the storage space provided on the public network, outbound traffic will be generated by sending files. When the code reads data or files from the storage space provided on the public network, outbound traffic will be generated only by sending requests but not by reading or downloading files.
    • If a function is configured with a VPC and writes data to a database in the VPC in its code, no outbound traffic will be generated by data writes.
    • For a function that uses an API Gateway trigger, no function outbound traffic will be generated by the data returned after the function is executed. The traffic generated by the data returned by API Gateway to the client will be calculated as the outbound traffic of and billed by API Gateway. For the billing rules of API Gateway traffic, please see Pay-As-You-Go.
    Note:

    Public network outbound traffic fees are charged only for access requests from functions to external resources. The capability for external invokers such as HTTP request or CDN action to trigger functions over the public network will be available in June 2021, and corresponding billing rules will be configured then.

    Idle Provisioned Concurrency Fees

    Idle provisioned concurrency fees = number of idle instances * configured memory size * idle duration * idle provisioned concurrency unit price

    • Number of idle instances: SCF counts the maximum concurrency of a version at a 10-second granularity. The number of idle instances is calculated by subtracting the maximum concurrency from the number of currently started provisioned instances. The calculation formula is as follows: number of idle instances = max(number of started provisioned instances - number of concurrent instances, 0).
    • Configured memory size: the memory size configured for the provisioned concurrency of the function.
    • Idle duration: the idle duration of the provisioned concurrency.
    • Idle provisioned concurrency price: please see Pricing.
    Note:

    Idle provisioned concurrency is calculated in GBs (GB-second).

    The provisioned concurrency feature only charges small idle fees for the instances that have been configured and started but are not in use, while no additional fees are charged for the instances that have been configured and are in use. In other words, only when the number of provisioned instances is greater than the number of concurrent instances for the current version will idle fees be incurred.

    The idle provisioned concurrency fees are calculated by multiplying the number of idle instances by the configured memory size. The shaded part in the figure below indicates the idle provisioned concurrency.

    For example, if a function version with 128 MB memory has a provisioned concurrency quota of 12,800 MB (10 instances), and it has 8 concurrent instances in 10 seconds, then:

    • Number of idle instances = max(10 - 8, 0) = 2
    • Configured memory size = 128MB
    • Idle duration = 10s
    • Idle provisioned concurrency price = 0.00000847 USD/GBs

    Idle provisioned concurrency fees = 2 * 128 / 1024GB * 10s * 0.00000847 USD/GBs = 0.00002118 USD

    Fees of Other Services

    If you use other services such as CMQ, CKafka, API Gateway, and COS when using SCF, fees will be calculated according to the billing rules of the actually used services.