With pay-as-you-go billing, MaxCompute charges for compute jobs including SQL, MapReduce, Spark, Mars (data science), Query Acceleration SQL, and MaxFrame. This topic describes the billing rules for each job type.
Background
MaxCompute uses job execution as the metering basis and charges you after a job is completed. Within a single region, an Alibaba Cloud account can purchase a pay-as-you-go quota only once.
MaxCompute currently charges for SQL, MapReduce, Spark, Mars (data science), Query Acceleration SQL, and MaxFrame jobs on a pay-as-you-go basis. If charges are introduced for other job types, we will provide separate announcements.
The billing methods for SQL, MapReduce, Spark, Mars, Query Acceleration SQL, and MaxFrame jobs are detailed below:
PyODPS tasks run as SQL jobs internally and are billed accordingly. For information about billing for other job types, see official Alibaba Cloud announcements.
Pay-as-you-go SQL jobs
For each SQL job you run, MaxCompute calculates the fee based on the input data size and SQL complexity. The system aggregates the fees for all successful SQL jobs within a project and adds the total to your bill on the following day before 06:00. The cost is then automatically deducted from your account balance.
You are not charged for failed SQL jobs.
Similar to storage, the input data size for an SQL job is calculated based on the compressed data size.
In bills and downloaded data records, the data size is measured in bytes. To convert this to gigabytes (GB), divide the value by 1024³.
SQL job cost estimation methods
SQL cost estimation helps predict fees and prevent unexpectedly high charges. The estimated cost may differ from the actual cost.
The final bill reflects the actual charges.
The following methods are available for estimating SQL costs.
Use DataWorks to develop SQL
The cost estimation feature in the GUI estimates fees. For more information, see Use DataWorks to develop SQL.
Use IntelliJ IDEA
The cost is automatically estimated when committing an SQL script. For more information, see Develop and commit SQL scripts.
During SQL development
Call the SQLCostTask API to estimate the SQL cost. For more information, see ODPS SDK.
In a production environment
Before you deploy an analytical SQL job, you can estimate its cost using the Cost SQL command. For more information, see Metering estimation.
Cost estimation is not supported for SQL jobs that involve external tables.
To prevent high daily spending, configure spending alerts in CloudMonitor. Setting a daily spending limit for each project allows you to monitor costs and avoid unexpected charges. For more information, see Consumption monitoring and cost control.
SQL job billing rules
The following table describes the billing rules for different types of SQL jobs.
Type | Billing formula | Price | Description |
Standard SQL jobs | Total daily fee for SQL jobs = Input data size × SQL complexity × Unit price |
| |
SpotSQL jobs | Total daily fee for SQL jobs = Input data size × SQL complexity × Unit price | In most cases, the unit prices are as follows:
| |
SQL jobs that query external tables, including:
| Total daily fee for SQL jobs = Input logical data size × SQL complexity × Unit price | In most cases, the unit prices are as follows:
| Billing for external tables started on October 31, 2018. For more information, see External tables.
|
Developer Edition SQL jobs | Total daily fee for SQL jobs = Input data size × Unit price | In most cases, the unit prices are as follows:
| The Pay-As-You-Go Developer Edition provides a CNY 100 discount on compute fees for each project every month. Note The Pay-As-You-Go Developer Edition is no longer available for new purchases and was discontinued at 00:00:00 on October 31, 2023 (Tuesday, UTC+8). For more information, see [Notice] MaxCompute Discontinues the Sales of Specific Instance Editions from September 23, 2022. |
Input data size: The amount of data that an SQL job actually scans. For most SQL jobs that use partition pruning and column pruning, this value is much smaller than the size of the source table.
Partition pruning: For example, if an SQL statement includes the clause
WHERE ds > 20130101, wheredsis a partition column, only the data in the partitions that meet the condition is billed. Data in other partitions is excluded.Column pruning: For example, for the SQL statement
SELECT f1,f2,f3 FROM t1;, only the data in columns f1, f2, and f3 of table t1 is included in the billing. Other columns are not billed.Logical size: The data size before compression and encoding.
SQL complexity: The system calculates the SQL complexity based on the number of specific keywords in an SQL statement.
Count the SQL keywords.
Number of SQL keywords = Number of JOINs + Number of GROUP BYs + Number of ORDER BYs + Number of DISTINCTs + Number of window functions +
MAX((Number of INSERTs | Number of UPDATEs | Number of DELETEs), 1). For more information about these keywords, see JOIN, GROUP BY, ORDER BY, window function, INSERT, and UPDATE|DELETE.NoteIf the number of SQL keywords is significantly higher than 20, parsing can take a long time and cause the job to remain in a queued state. We recommend that you optimize your SQL to reduce the number of keywords.
Calculate SQL complexity.
If the keyword count is 3 or less, the complexity is 1.
If the keyword count is between 4 and 6 (inclusive), the complexity is 1.5.
If the keyword count is between 7 and 19 (inclusive), the complexity is 2.
If the keyword count is 20 or more, the complexity is 4.
SQL job billing example
Consider the following SQL statement:
SELECT DISTINCT total1
FROM(SELECT id1,
COUNT(f1) AS total1
FROM in1
GROUP BY id1
) tmp1
ORDER BY total1 DESC
LIMIT 100;Number of
DISTINCT: 1Number of
GROUP BY: 1Number of
ORDER BY: 1MAX((Number of INSERTs | Number of UPDATEs | Number of DELETEs), 1) = MAX(0|0|0, 1) = 1Total number of SQL keywords = 1 + 1 + 1 + 1 = 4
The total keyword count is 4, which falls into the range of 4 to 6. Therefore, the SQL complexity is 1.5.
Pay-as-you-go MapReduce jobs
After a MapReduce job runs successfully, the system calculates the fee based on the compute hours consumed. The system aggregates the fees for all successful MapReduce jobs and adds the total to your bill on the following day before 06:00. The cost is then automatically deducted from your account balance.
You are not charged for failed MapReduce jobs.
You are not charged for the time a job spends in the queue.
The cost of the same job may vary slightly due to fluctuations in the cluster load.
One Compute Unit (CU) is equivalent to 1 CPU core-hour and 4 GB-hours of memory. Compute hours are calculated using the greater value between CPU and memory consumption over time, based on the formula: MAX(CPU Cores × Hours, CEILING(Memory in GB × Hours / 4)).
If you have a MaxCompute subscription, you can run MapReduce jobs for free within the scope of your subscription plan.
If you have any questions about MapReduce job billing, you can submit a ticket to contact MaxCompute technical support.
MapReduce job billing rules
Billing formula | Type | Price | Description | Example |
| Standard MapReduce jobs | In most cases, the unit prices are as follows:
| Starting from August 16, 2017, MaxCompute began billing for MapReduce jobs on a pay-as-you-go basis. By default, a Map or Reduce job uses 2 cores and 3 GB of memory. | A MapReduce job uses 2 cores and 10 GB of memory for 1 hour. The compute hours are calculated as The total compute fee for the MapReduce job is calculated as follows:
|
Spot MapReduce jobs | In most cases, the unit prices are as follows:
| A Spot MapReduce job uses 2 cores and 10 GB of memory for 1 hour. The compute hours are calculated as The total compute fee for the Spot MapReduce job is calculated as follows:
|
Pay-as-you-go Query Acceleration SQL jobs (applicable only to MCQA)
For each Query Acceleration job you run, MaxCompute calculates the fee based on its input data size. The system aggregates the fees for all Query Acceleration jobs and adds the total to your bill on the following day before 06:00. The cost is then automatically deducted from your account balance.
The pay-as-you-go billing method for Query Acceleration jobs is available in the China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Ulanqab), China (Shenzhen), and China (Chengdu) regions. This service is being gradually rolled out to other regions.
MaxCompute uses columnar storage and data compression by default. The scanned data size is calculated based on the compressed data size.
You are not charged for canceled Query Acceleration jobs.
No fees are incurred if you do not run any queries.
When you query a partitioned table, you can use partition pruning conditions to reduce the amount of scanned data and improve query performance.
If you have a subscription plan, you can allocate a portion of your quota resources exclusively for Query Acceleration jobs. For more information, see MaxQA overview.
Billing rules
Billing formula | Price | Description |
Fee for one Query Acceleration job = Input data size × SQL complexity × Unit price | In most cases, the unit prices are as follows:
| Starting from October 12, 2020, MaxCompute began billing for Query Acceleration jobs on a pay-as-you-go basis. For more information, see MaxQA overview. |
Pay-as-you-go Spark jobs
After a Spark job runs successfully, the system calculates the fee based on the compute hours consumed. The system aggregates the fees for all Spark jobs and adds the total to your bill on the following day before 06:00. The cost is then automatically deducted from your account balance.
The pay-as-you-go billing method for Spark jobs is available in the China (Hangzhou), China (Beijing), and China (Shenzhen) regions. This service is being gradually rolled out to other regions.
You are not charged for the time a job spends in the queue.
The cost of the same job may vary depending on the amount of resources you specify.
If you have a MaxCompute subscription, you can run Spark jobs for free within the scope of your subscription plan.
If you have any questions about Spark job billing, you can submit a ticket to contact MaxCompute technical support.
Spark job billing rules
Billing formula | Type | Price | Description | Example |
Total daily compute fee for Spark jobs = Total daily compute hours × Unit price | Standard Spark jobs | In most cases, the unit prices are as follows:
| Starting from February 1, 2019, MaxCompute began billing for Spark jobs on a pay-as-you-go basis. For more information, see Spark on MaxCompute. The compute hours for a Spark job are calculated as follows:
| A Spark job uses 2 CPU cores and 5 GB of memory and runs for 1 hour. The compute hours are calculated as The compute fee for the Spark job is |
Spot Spark jobs | In most cases, the unit prices are as follows:
| A Spot Spark job uses 2 CPU cores and 5 GB of memory and runs for 1 hour. The compute hours are calculated as The compute fee for the Spot Spark job is |
Pay-as-you-go Mars (data science) jobs
After a Mars job runs successfully, the system calculates the fee based on the compute hours consumed. The system aggregates the fees for all Mars jobs and adds the total to your bill on the following day before 06:00. The cost is then automatically deducted from your account balance.
The pay-as-you-go billing method for Mars jobs is available in the China (Hangzhou), China (Shanghai), China (Beijing), China (Zhangjiakou), China (Ulanqab), China (Shenzhen), China (Chengdu), and China (Hong Kong) regions. This service is being gradually rolled out to other regions.
You are not charged for the time a job spends in the queue.
The cost of the same job may vary depending on the amount of resources you specify.
If you have a MaxCompute subscription, you can run Mars jobs for free within the scope of your subscription plan.
If you have any questions about Mars job billing, you can submit a ticket to contact MaxCompute technical support.
Mars job billing rules
Billing formula | Type | Price | Description | Example |
Total daily compute fee for Mars jobs = Total daily compute hours × Unit price | Standard Mars jobs | In most cases, the unit prices are as follows:
| Starting from September 1, 2020, MaxCompute began billing for Mars jobs on a pay-as-you-go basis. For more information, see Data science (Mars). The compute hours for a Mars job are calculated as follows:
| A Mars job uses 2 CPU cores and 5 GB of memory and runs for 1 hour. The compute hours are calculated as The compute fee for the Mars job is |
Spot Mars jobs | In most cases, the unit prices are as follows:
| A Spot Mars job uses 2 CPU cores and 5 GB of memory and runs for 1 hour. The compute hours are calculated as The compute fee for the Spot Mars job is |
Pay-as-you-go MaxFrame jobs
After a MaxFrame job runs, the system calculates the fee based on the CU hours (compute hours) consumed. The system aggregates the fees for all MaxFrame jobs and adds the total to your bill on the following day before 06:00. The cost is then automatically deducted from your account balance.
The pay-as-you-go billing method for MaxFrame jobs is available in the China (Hangzhou), China (Beijing), China (Shenzhen), China (Shanghai), China (Chengdu), and China (Hong Kong) regions. This service is being gradually rolled out to other regions.
If you have a MaxCompute subscription, you can run MaxFrame jobs for free within the scope of your subscription plan.
If you have any questions or require assistance with MaxFrame job billing, you can submit a ticket to contact MaxCompute technical support.
MaxFrame job billing rules
Billing formula | Type | Price | Description | Example |
Total daily compute fee for MaxFrame jobs = Total daily CU hours × Unit price | Standard MaxFrame jobs | In most cases, the unit prices are as follows:
| The CU hours for a MaxFrame job are calculated as follows:
| A MaxFrame job uses 2 CPU cores and 5 GB of memory and runs for 1 hour. The CU hours are calculated as The compute fee for the MaxFrame job is |
Related documents
Analyze your MaxCompute bills to understand cost distribution, prevent budget overruns, maximize resource utilization, and reduce costs. For more information, see Analyze the details of a MaxCompute bill.
If your daily costs spike unexpectedly for reasons other than business growth, analyze your spending to identify the responsible projects and jobs. This allows you to optimize them and control costs promptly. For more information, see Troubleshoot unexpected increases in pay-as-you-go resource consumption for MaxCompute.