All Products
Search
Document Center

MaxCompute:Use quota groups for computing resources

最終更新日:Nov 05, 2024

A quota group is a computing resource pool of MaxCompute and provides the required computing resources, such as CPU cores and memory, for computing jobs in MaxCompute. MaxCompute allows you to specify quota groups for computing jobs based on the computing resource requirements of the computing jobs. This helps you use computing resources in an efficient manner. This topic describes how to use quota groups of MaxCompute.

Background information

MaxCompute allows you to use computing resources in a quota group in one of the following ways:

  • Specify a default quota group for a project. This way, all jobs that are committed in the project use this quota group for computation.

  • Specify a quota group at the job level. This way, you can specify different quota groups for jobs in a project for computation. Quota groups are classified into subscription quota groups and pay-as-you-go quota groups. The priority of a quota group that is specified at the job level is higher than the priority of the default quota group of a project.

  • Configure rules for quota groups. This way, a job that meets the specified rule can be scheduled to the related quota group.

Specify a default quota group for a project

If you specify a default quota group for a project, the jobs that are initiated in this project use the computing resources of the default quota group for computation by default. You do not need to configure additional settings. When you create a project, you can specify a default quota group for the project. You can also find the project and click Switch quota group in the Actions column on the Projects page in the MaxCompute console to change the default quota group of the project. For more information, see Configure a project.

Specify a quota group at the job level

You can add a SET command before the SQL statement of a job to specify a quota group for the job. This feature checks whether the job owner has the permissions to use the quota group. This section describes the procedure.

  1. Create a quota group.

    For more information about how to create a quota group in the new MaxCompute console, see Configure quotas.

    Note

    We recommend that you use a combination of letters and digits when you specify a quota group name. The existing Chinese quota group names can still be used.

  2. Grant required permissions.

    By default, all Alibaba Cloud accounts, RAM users, and roles do not have permissions to specify a quota group for a job. An account can be used to specify a quota group for a job only after the account is granted the required permissions.

    1. Create a role.

      1. Log on to the MaxCompute console. In the top navigation bar, select a region.

      2. In the left-side navigation pane, choose Tenants > Roles.

      3. On the Roles page, click Add Role.

      4. In the Add Role dialog box, configure the Role Name parameter and enter the following policy document:

        {
            "Statement": [{
                    "Action": [
                        "odps:List",
                        "odps:Usage"],
                    "Effect": "Allow",
                    "Resource": ["acs:odps:*:regions/*/quotas/*"]}],
            "Version": "1"
        }

        The following table describes the parameters in the sample code.

        Parameter

        Description

        Action

        The action that is allowed or denied. You can specify multiple actions for a single authorization operation based on your business requirements. If you specify multiple actions, separate the actions with commas (,). For more information about the supported actions, see MaxCompute permissions.

        Note

        For more information about policy parameters, see Policy elements.

        Resource

        The authorized resource range. Configure this parameter in the ["acs:odps:Tenant/${tenant_id}:regions/${region_id}/quotas/${quota_name}"] format.

        ["acs:odps:*:regions/*/quotas/*"] specifies all quota groups in all regions for the current tenant. You can specify a specific region and a specific quota group based on your business requirements.

      5. Click OK.

    2. Assign the role that you created to the account that you want to use to specify the quota group at the job level.

      Note

      By default, the Alibaba Cloud account or a RAM user that is assigned the tenant-level Super_Administrator role can perform the authorization operations.

      The authorization operations vary based on the type of the object to which permissions are granted.

      • Alibaba Cloud account

        To grant permissions to an Alibaba Cloud account, run the following commands:

        -- Add the Alibaba Cloud account to the current tenant and assign the specified role to the Alibaba Cloud account.
        Add tenant user <Aliyun$xxxx>;
        Grant tenant role <role_name> to user <Aliyun$xxxx>;
        -- View the permissions of the tenant-level role or user.
        Show grants for tenant role <role_name>;
        Show grants for tenant user <user_name>;
        Show principals for tenant [role] <role_name>;
      • RAM user

        1. In the left-side navigation pane of the MaxCompute console, choose Tenants > Users.

        2. On the Users page, find the required RAM user and click Modify Role in the Actions column.

        3. In the Edit Role dialog box, select the required role in the Available Roles section to add the role to the Added Roles section.

        4. Click OK.

  3. Specify the quota for a job.

    Add the following command before the SQL statement of the job to specify the previously created quota for the job:

    set odps.task.wlm.quota=<quotaname>; 

    quotaname specifies the name of the quota. This parameter is valid only for quotas of the batch processing type.

    Note

    If you want to specify a quota for your Spark job, you must add the configuration odps.task.wlm.quota = <quotaname>.

    For MaxCompute Query Acceleration (MCQA) jobs, take note of the following points:

    • You cannot use the preceding command to directly specify an interactive quota. An interactive quota can be automatically selected by the system only when MCQA is enabled. For more information, see MaxCompute Query Acceleration.

    • If you run the set odps.task.wlm.quota=<quotaname>; command to specify a quota for an MCQA job, the job is rolled back to run in the quota specified by quotaname when the job fails to run in the interactive quota. In this case, the quota specified by quotaname is not selected as a quota for the MCQA job. Therefore, the MCQA job still consumes the resources in the default computing quota associated with the project in which the MCQA job is run.

    • If you do not explicitly specify the odps.task.wlm.quota parameter, the interactive task attempts to roll back to the quota that is specified by quota rules. If no quota rule is configured, the task rolls back to the default quota of the project.

Quota rules

MaxCompute allows you to configure quota rules. This way, jobs that meet the rules can be scheduled to use the related quota.

Limits

  • You can configure rules for the level-2 quotas that are created in the pay-as-you-go Spot Edition of MaxCompute and subscription level-2 quotas.

  • You can configure a maximum of 10 rules for each level-2 quota.

  • You can configure a maximum of 50 items in each of the Project and Job Owner fields for each rule. This indicates that you can configure a rule for a maximum of 50 projects and 50 job owners (UIDs).

  • You can enter a maximum of five key-value pairs in the Job Settings field for each rule.

  • Valid values of the Job Priority parameter for each rule: [0, 9].

Configure quota rules

A quota rule takes effect after you configure the rule. You can delete the rules that you do not require. Multiple rules have the OR relationship. If a job matches one of the rules of a quota, the job can be scheduled to use the quota or is forbidden to use the quota based on the rule mode.

Note

Quota rules, especially the rules that you configured in the Job Settings field, are flexible. To prevent O&M difficulties due to excessive rules, we recommend that you configure only rules that you require.

  1. Log on to the MaxCompute console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, choose Workspace > Quotas.

  3. On the Quotas page, find the desired level-1 quota and click the 列表 icon to the left of the level-1 quota to expand the level-2 quotas of the quota.

  4. Find the level-2 quota that you want to manage and click Rule Configuration in the Actions column.

  5. In the Quota Rule Configuration dialog box, click Add Rule or find an existing rule and click Clone in the Actions column to create a rule.

    Note
    • The AND relationship exists among multiple projects, job types, and job settings that are configured in a rule.

    • A rule takes effect about 5 minutes after it is configured.

    The following table describes the parameters in the Add Rule dialog box.

    Parameter

    Description

    Rule Name

    The name of the custom quota rule.

    The name can contain only letters, digits, and underscores (_) and must start with a letter.

    Rule Mode

    The mode of the quota rule. Valid values:

    • NORMAL: normal mode.

      In this mode, the following mechanisms are provided to schedule a job to use a quota based on the characteristics of the job:

      • If a job matches a rule of a quota, the job is scheduled to use the quota.

      • If a job matches multiple quota rules at the same time, the job is scheduled to use the quota that is created earliest.

      • If a job does not match any quota rule, the job uses the default quota of the project regardless of whether the job matches the rules of the default quota.

      • If the etl_1 quota is specified for a job based on the job level, the job is scheduled to use the etl_1 quota regardless of whether the job matches the rules of the etl_1 quota.

    • EXCLUSIVE: exclusive mode.

      If a job matches a rule in exclusive mode of a quota based on the characteristics of the job, the job is scheduled to use the quota. Otherwise, the job cannot be scheduled to use the quota.

      The following examples show the differences between the normal mode and the exclusive mode.

      • For example, the etl_2 quota is the default quota that is associated with the Project_2 project, and rules that run in exclusive mode are configured for the etl_2 quota. If a job that is initiated by the Project_2 project cannot match the rules of the etl_2 quota, the default quota cannot be selected for the job. In this case, an error is reported when the job is submitted. However, if you configure only rules that run in normal mode for the etl_2 quota, the job can be scheduled to use the etl_2 quota.

      • For example, the set odps.task.wlm.quota=etl_3 (i.e. use quota etl_3) command is run to specify the etl_3 quota for a job. If a rule that runs in exclusive mode is configured for the etl_3 quota but the job does not match the rule, an error is reported when the job is submitted. However, if you configure only rules that run in normal mode for the etl_3 quota, the job can be scheduled to use the etl_3 quota.

    • ANTI: prohibited mode.

      If a job matches a rule in prohibited mode of a quota based on the characteristics of the job, the job is forbidden to use the quota. The job is preferentially scheduled to use the default quota group of the project to which the job belongs. If the default computing quota of the project is the quota that the job is forbidden to use, the job is scheduled to use the quota that is created earliest in the current region. The pay-as-you-go quota is included.

    Important

    The rules that run in exclusive mode and the rules that run in prohibited mode have higher priorities than the rules that run in normal mode. If the job does not match a rule that runs in exclusive mode of Quota A or matches a rule that runs in prohibited mode, the job cannot be scheduled to use Quota A regardless of whether the job matches a rule that runs in normal mode of Quota A or is manually specified to use Quota A.

    Project

    The projects that you want to configure in the rule. You can configure a maximum of 50 projects.

    Job Type

    The types of jobs that you want to configure in the rule.

    Valid values:

    • SQL: SQL jobs

    • SQLRT: MaxCompute MCQA SQL jobs

    • SQLCost: SQL cost estimation jobs

    • LOT: MapReduce jobs

    • CUPID: Spark or Mars jobs

    • AlgoTask: Platform for AI (PAI) jobs

    Job Priority

    The priorities of jobs that you want to configure in the rule. You can enter a value ranging from 0 to 9 to specify the priorities of jobs. For example, if you enter [0,3], the priorities of jobs are 0, 1, 2, and 3.

    Job Owner (Account ID)

    The user IDs of the job owners that you want to configure in the rule. You can enter a maximum of 50 user IDs. Multiple user IDs have the OR relationship. Each user ID occupies a single line.

    If the p4_ prefix needs to be added to the user ID of a RAM user, the user ID is p4_12344566777. If the v4_ prefix needs to be added to the user ID of a RAM role, the user ID is v4_12344566776.

    Job Settings

    You can enter one or more key-value pairs that are in the Key=Value format. No quotation marks are required. Multiple key-value pairs have the AND relationship. Each key-value pair occupies a single line. You can enter a maximum of five key-value pairs.

    For example, if you want to run all data backfill jobs that are initialized by an auto triggered task of DataWorks in the current quota, enter SKYNET_DAGTYPE=3 in the Job Settings field. For more information, see Isolate data backfill jobs.

  6. Click OK.

Examples

  • Schedule an MCQA job

    • Acceleration quota and rollback quota

      An MCQA job requires an acceleration quota and a rollback quota. The acceleration quota is of the interactive type and the rollback quota is of the batch type. If a job that uses the acceleration quota times out or a job is rejected to use the acceleration quota due to reasons such as the job type, the system resubmits the job in the rollback quota. You can create a quota rule to add a project or a job owner to both an acceleration quota and a rollback quota to implement the preceding logic.

    • Enable MCQA by project or job owner

      To enable interactive quotas by project, you can configure different ProjectList rules for different quotas when you create interactive quotas.

  • Isolate data backfill jobs

    A data backfill job is used to update data. If the data backfill process requires a long period of time, a large number of resources are consumed. To prevent the impact of excessive resource consumption on your daily jobs, you can create a quota and configure rules for the quota to exclusively run data backfill jobs. For example, if the data backfill job that is initiated by an auto triggered task of DataWorks fixedly passes the SKYNET_DAGTYPE:3 parameter to the Job Settings field, you can configure the following quota rules:

    • Create a quota named refill and configure rules for the refill quota. If you want to allow all data backfill jobs that are initiated by an auto triggered task of DataWorks to be automatically scheduled to use the refill quota, you can configure rules that run in normal mode. To configure a rule that runs in normal mode, you need to only enter SKYNET_DAGTYPE=3 in the Job Settings field.

    • You can also configure parameters in a fine-grained manner. For example, if you want only data backfill jobs whose priorities range from 5 to 9 of the P1 project to be scheduled to use the refill quota, perform the following steps to configure a rule that runs in normal mode: Set Project to P1, enter [5,9] in the Job Priority field, and then enter SKYNET_DAGTYPE=3 in the Job Settings field.

      Note

      The priority that is configured in the rule is the priority in MaxCompute but not the baseline priority in DataWorks. Priority in MaxCompute = 9 - Baseline priority in DataWorks.

  • Isolate jobs that are initiated by different roles

    Jobs, such as data analytics jobs, scheduled report jobs, and data backfill jobs, may be initiated by different business personnel. The jobs may also come from different departments that have different resource budgets. Therefore, multiple quotas must be created to allow jobs that are initiated by different roles to use different quotas.

    In most cases, you can identify the roles of jobs based on the following parameters: Project, Job Owner (Account ID), Job Type, Job Priority, and Job Settings.

    • If jobs that are initiated by different roles use different projects, you can set the Project parameter to the names of the required projects in the rule that you want to create for the desired quota.

    • If jobs that are initiated by different roles are submitted by different users, you can enter the user IDs of the job owners in the Job Owner (Account ID) field in the rule that you want to create for the desired quota.

    • If jobs that are initiated by different roles have different configurations, you can configure Job Settings to distinguish between the roles of the jobs. Job Settings specifies the SET xxx=xxx; statements that are submitted together with the job. The SET statements are classified into custom statements and statements that are automatically added. For example, if a job is initiated by using DataWorks, specific parameters are automatically configured to help identify the job.

    • If different roles submit different job types, you can identify the job type based on the value of the Job Type parameter. For example, the value of the Job Type parameter for a PAI job that is submitted by using PAI is ALGO, and the value of the Job Type parameter for a normal SQL query job that is submitted by using MaxCompute is SQL.

    The preceding rules can be used together to perform finer-grained job scheduling.