All Products
Search
Document Center

MaxCompute:Consumption control

Last Updated:Sep 21, 2023

This topic describes how to impose limits on the pay-as-you-go resources that are consumed by computing jobs.

Description

Pay-as-you-go resources in MaxCompute are scalable. Computing jobs can use these resources without limits. To prevent unexpected 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 you execute an SQL statement, you can estimate 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

You can configure an upper limit for the resources that are consumed by an SQL statement for a project or a session.

  • 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 limit on the resources that are consumed by an SQL statement. 
    setproject odps.sql.metering.value.max=<m_value>;
    
    -- Remove an 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.

    set odps.sql.metering.value.max=<m_value>;

m_value specifies an upper limit for the resources that are consumed by an SQL statement. m_value is calculated by using the following formula: m_value = Number of gigabytes read by an SQL statement × Complexity of the SQL statement. m_value does not indicate your consumption fees.

Note

The resources that can be consumed by an SQL statement for a project are limited by m_value. If the estimated consumption value of an SQL statement exceeds the value of m_value, the SQL statement cannot be executed. The resource consumption of some SQL statements, such as SQL statements in which external tables are involved, cannot be estimated. In this case, consumption control does not take effect for the SQL statements.

Take note of the following points:

  • 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 ComputationSql 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 consumption control.

    • 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 project-level upper limit. If the estimated resource consumption value exceeds 100, these SQL statements cannot be executed.

  • The execution of a job is affected if you configure an upper limit for a project or session. We recommend that you use the consumption control 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.