This topic describes how to control the consumption of pay-as-you-go resources for computing jobs.
Pay-as-you-go resources in MaxCompute are scalable. Your computing jobs can consume these resources based on your business requirements. To prevent unexpected resource consumption, we recommend that you monitor the resource consumption of computing jobs.
MaxCompute allows you to configure an upper limit for the resources that are consumed by an SQL statement. Before an SQL statement is executed, MaxCompute estimates the resources to be consumed by this statement. If the estimated consumption exceeds the specified upper limit, the SQL statement cannot be executed, and a failure message is returned. You can use this feature to prevent unexpected charges caused by an SQL statement.
Configure an upper limit for the resources that are consumed by an SQL statement
- Configure an upper limit for a project. The project owner or users assigned with the Super_Administrator role can impose or remove the upper limit on or from the resources that are consumed by an SQL statement. The configuration takes effect for all subsequent SQL jobs whose resource consumption can be estimated in a project.
-- Impose the upper limit on the resources that are consumed by an SQL statement. setproject odps.sql.metering.value.max=<m_value>; -- Remove the upper limit from the resources that are consumed by an SQL statement. setproject odps.sql.metering.value.max;
- Configure an upper limit for a session. You can submit the following command with the SQL statement that you want to execute to impose the upper limit on the resources that are consumed by the SQL statement. If the command is not added before the SQL statement, the upper limit is removed. The configuration takes effect only for the current statement.
m_value = Number of gigabytes read by an SQL statement × Complexity of the SQL statement. m_value does not indicate your consumption fees.
- We recommend that you specify m_value for a project based on the historical consumption records and resources that are expected to be consumed by an SQL statement.
You can download daily consumption information and calculate the consumption of an SQL statement whose data category is computation in a project by using the following formula:
Consumption of an SQL statement = Number of gigabytes read by the SQL statement × Complexity of the SQL statement. After the calculation is complete, you can determine the value of m_value based on the maximum daily consumption and business fluctuation.
You can also convert computing resource consumption into fees, determine an appropriate amount of fees based on your business requirements, and then convert the fees into a consumption value.
- We recommend that you specify m_value for a project and then for a session for some SQL statements. Note
- Before you configure an upper limit for an SQL statement at the session level, you must make sure that this upper limit is required for the SQL statement. This prevents abuse of this feature.
- If you configure an upper limit for both a project and its session, the configuration for the session takes precedence over the configuration for the project. For example, if you set m_value to 100 for a project and 200 for a session in the project, the SQL statement cannot be executed if the estimated resource consumption value exceeds 200. SQL statements that do not have a session-level upper limit are subject to the upper limit at the project level. If the estimated resource consumption value exceeds 100, these SQL statements cannot be executed.
- The execution of a job is affected no matter whether you configure an upper limit for a project or session. We recommend that you use this feature with the job failure alerting feature, such as the intelligent monitoring feature of DataWorks. This way, failed jobs are immediately detected and processed to minimize the impact of these jobs on your business.