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 avoid unexpected consumption, we recommend that you monitor the resources consumed by 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

You can configure an upper limit for the resources that are consumed by an SQL statement for a project or session.
  • Configure an upper limit for a project. You can run one of the following commands to impose or remove the limit on or from the resources that are consumed by an SQL statement. Make sure that you are the project owner or have been assigned the Super_Administrator role.
    -- Impose the limit on the resources that are consumed by an SQL statement.
    setproject odps.sql.metering.value.max=<m_value>;
    
    -- Remove the limit from the resources that are consumed by an SQL statement.
    setproject odps.sql.metering.value.max;

    m_value indicates 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 scanned by an SQL statement × Complexity of the SQL statement. m_value does not indicate your consumption fees.

    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 m_value, the SQL statement cannot be executed.

  • Configure an upper limit for a session. You can submit the following command with the SQL statement to impose the limit on the resources that are consumed by the SQL statement. If the command is not added before the SQL statement, the limit is removed. This configuration takes effect for the specified SQL statement only once.
    set odps.sql.metering.value.max=<m_value>;

If you configure an upper limit for both a project and its session, the configuration for the session takes precedence over that for the project. For example, if you set m_value to 100 for a project and 200 for a session in the project, the statement cannot be executed only if the estimated resource consumption 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 exceeds 100, these SQL statements cannot be executed.

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 computation in a project by using the following formula: Consumption of an SQL statement = Number of gigabytes scanned by the SQL statement × Complexity of the SQL statement. After the calculation is complete, you can determine an appropriate m_value based on the maximum daily consumption and business fluctuation.

    You can also convert the calculated consumption to consumption fees. This way, you can determine the fees based on business conditions and convert the fees to an m_value.

  • We recommend that you specify m_value for a project and then sessions for some SQL statements.
    Note Before you configure an upper limit for an SQL statement at the session level, make sure that this upper limit is required for the SQL statement. This avoids abuse of this feature.
  • 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 features that provide alerts related to job execution failures, for example, 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.