This topic describes how to view the billing details and usage records of MaxCompute. This topic also describes how to analyze billing details in common scenarios.

Go to Billing Management

Log on to the Alibaba Cloud Management Console. In the top navigation bar, click Expenses. Expenses
Note Before you access Billing Management as a RAM user, you must attach the AliyunBSSFullAccess policy to the RAM user by using your Alibaba Cloud account. For more information, see Grant permissions to a RAM role.

View billing details

  • Query daily bills.
    1. In the left-side navigation pane, choose Spending Summary > Spending Summary. On the Bills page, click the Bills tab.
    2. Click the Filter icon next to Product Name and select MaxCompute to view the daily bills of MaxCompute. Bill details
      Description:
      • MaxCompute (Pay-As-You-Go) with Subscription Type set to Pay-As-You-Go: All pay-as-you-go bills that are generated for the pay-as-you-go resource packages of MaxCompute on the day. You are billed for the storage resources, computing resources, and the traffic for Internet-based data downloads in these packages based on the pay-as-you-go billing method.
      • MaxCompute (Subscription) with Subscription Type set to Pay-As-You-Go: All pay-as-you-go bills that are generated for the subscription resource packages of MaxCompute on the day. You are billed for the storage resources and the traffic for Internet-based data downloads in these packages based on the pay-as-you-go billing method.
      • MaxCompute (Subscription) with Subscription Type set to Subscription: All subscription bills that are generated for the subscription resource packages of MaxCompute on the day. You are billed for all new purchases, configuration upgrades and downgrades, and package renewals based on the subscription billing method.
  • Query the daily consumption details of pay-as-you-go billable items.
    1. On the Bills page, click the Details tab.
    2. Select Billing Item for Statistic Item, By Day for Statistic Period, and Pay-As-You-Go for Subscription Type.
    3. Click the Filter icon next to Product Name and select MaxCompute to view the daily bills for each billable item. **
      Description:
      • Instance ID: corresponds to a MaxCompute project. Pay-as-you-go bills are generated by project. A bill is generated for each billable item each day.
      • Billing Item: includes storage, computing, and the traffic for Internet-based data downloads.
      • Usage:
        The usage of each billable item is calculated based on the following description:
        • Storage: the storage used for the project on the day divided by 24
        • Traffic for Internet-based data downloads: the amount of data that is downloaded over the Internet for the project on the day
        • Computing for SQL jobs: the amount of input data for the standard SQL jobs that are successfully executed for the project on the day multiplied by SQL complexity
        • Computing for SQL jobs that involve external tables: the amount of input data for the SQL jobs of the project on the day
        • Computing for SQL jobs that use developer resources: the amount of input data for the successfully executed SQL jobs of the project that uses developer resources on the day
        • Computing for MapReduce jobs: the billable hours used by the MapReduce jobs that are successfully executed for the project on the day
        • Computing for Lightning jobs: the amount of input data for the Lightning jobs that are successfully executed for the project on the day
        • Computing for Spark jobs: the billable hours used by the Spark jobs that are successfully executed for the project on the day

You can select other values for Statistic Item and Statistic Period to view billing details from different dimensions. You can also click Export Billing Overview (CSV) in the upper-right corner to download the bills to your on-premises machine and analyze the bills in an Excel file. However, the billing details do not provide the consumption of a single job. To view the consumption of a job, download usage records to obtain the original metering information and calculate the consumption of a job.

Usage records

Download usage records

Go to the Usage Records page to download and view the daily resource usage records and check how costs are generated. For example, you can check the storage and computing costs of each day and determine from which jobs the costs are generated. Usage records
Configure the following parameters:
  • Product: the service for which you want to download usage records. Set this parameter to MaxCompute (Pay-As-You-Go).
  • Billing Method:
    • MaxCompute(Postpay): the pay-as-you-go billing method
    • ODPSDataPlus: the subscription billing method
  • Time Period: the time range within which you want to query data. You can specify the start time and end time of the bills that you want to view.

    If you start a job on December 1 and the job is completed on December 2, you must set the start time of the time range to December 1. Otherwise, you cannot find the resource usage of the job in the downloaded usage records. The resource consumption record of the job is displayed in the bill that is generated on December 2.

Use usage records

After you export usage records to your on-premises machine as a CSV file, use Microsoft Excel to open the file and view the usage records. The following information shows a usage record:
-- The CSV file includes the following table headers: 
ProjectId, MeteringId, MeteringType, Storage, EndTime, SQLInput(Byte), SQLComplexity, UploadEx, DownloadEx(Byte), MRCompute(Core*Second), InputOTS(Byte), InputOSS(Byte), StartTime, SpecificationType, and DataWorksNodeID
The usage records allow you to perform the following operations:
  • View the instance ID of each SQL or MapReduce job and run the following command to view details about the job:
    odps@ odps_test>desc instance 2016070102275442go3xxxxxx;
    ID 2016070102275442go3xxxxxx
    Owner ALIYUN$***@aliyun-inner.com
    StartTime 2016-07-01 10:27:54 
    EndTime 2016-07-01 10:28:16
    Status Terminated 
    console_query_task_1467340078684 Success 
    Query select count(*) from src where ds='20160628';
    Note You can also use the TASKS_HISTORY and TUNNELS_HISTORY views of MaxCompute Information Schema to view the execution information of a specific job. For more information, see Information Schema. However, the views provide the execution information only for the last 15 days.
  • Analyze the original metering information of each SQL or MapReduce job and calculate the cost of the job based on the formula that is described in Computing pricing. Examples:
    • Calculate the costs of standard SQL jobs. ComputationSql in the MeteringType column indicates a standard SQL job. You can calculate the cost of a standard SQL job by using the following formula: Cost of a standard SQL job = Amount of input data (GB) × SQL complexity × SQL job unit price.
    • Calculate the costs of SQL jobs that involve external tables, such as Tablestore and Object Storage Service (OSS) external tables. The value in the InputOTS(Byte) or InputOSS(Byte) column in the CSV file indicates the amount of input data for an SQL job that involves external tables. You can calculate the cost of an SQL job that involves external tables by using the following formula: Cost of an SQL job = Amount of input data × SQL complexity × Unit price for SQL computing jobs that involve external tables.

      The unit price for an SQL job that involves external tables is USD 0.0044/(GB × Complexity). The complexity coefficient is 1.

    • Calculate the costs of MapReduce jobs. You can query the resources and time consumed by a MapReduce job in the MRCompute(Core*Second) column.

Bill analysis of common scenarios

  • Analyze unexpected cost surges
    If your costs surge in one or a few days but the surge is not caused by business growth, perform the following operations to analyze the cause:
    1. Analyze the projects that generate high costs: On the Details tab of the Bills page, select Instance for Statistic Item and By Day for Statistic Period. Then, find the projects that generate high costs based on instance IDs. If the consumption of a project is not as expected, analyze the project.
    2. Analyze the billable items that generate high costs: On the Details tab of the Bills page, select Billing Item for Statistic Item and By Day for Statistic Period. Then, find the billable items that generate high costs. You can search for a project based on Instance ID and analyze its billable items that generate high costs. **
    3. Analyze computing tasks that generate high costs. If the preceding analysis indicates that the costs of SQL computing jobs surge, you can choose Bill > Usage Record and download usage records. Then, you can analyze the records where MeteringType is set to ComputationSql. Sort the costs of SQL jobs and check whether the costs of some SQL jobs are higher than expected or whether a large number of SQL jobs exist. You can calculate the cost of an SQL job by using the following formula: Cost of an SQL job = SQLInput(Byte)/1024/1024/1024 × SQL complexity × SQL job unit price. If the cost of an SQL job is higher than expected, we recommend that you check the ID of the DataWorks scheduling node on which the job runs based on the metering information.
      • If the ID is available, view the execution details of the job in the DataWorks console.
      • If the ID is unavailable, the job is not initiated by a DataWorks scheduling node. In this case, view the execution details of the job by using the SQL billing code indicated by Instance ID and the TASKS_HISTORY view of MaxCompute Information Schema. For more information about TASKS_HISTORY, see TASKS_HISTORY.
        select operation_text from information_schema.tasks_history where ds='Partition that corresponds to the date on which the job runs' and inst_id='SQL billing code indicated by Instance ID';
  • Check whether data uploads and downloads generate costs
    You can perform the following operations to check the costs generated by data uploads and downloads:
    1. Export usage records as a CSV file and analyze the billing details for data downloads. DownloadEx in the file indicates the billable item for an Internet-based data download.
    2. For example, you find a record for download traffic of 0.036 GB (38,199,736 bytes). In this case, calculate the cost based on the billing rules described in Download pricing (pay-as-you-go) by using the following formula: (38,199,736 bytes/1024/1024/1024) × USD 0.1166/GB = USD 0.004.

    3. Optimize data downloads.

      You can also check whether the service configured for your tunnel is billed due to Internet access. For more information, see Endpoints.

      For example, you are located in Suzhou, China, which belongs to the China (Shanghai) region, and want to download large amounts of data. In this case, use an Elastic Compute Service (ECS) instance in the China (Shanghai) region to download data to your virtual machine (VM). Then, use your subscription ECS instance to download the data.

  • Analyze how the storage used in part of a day is billed
    1. Export usage records as a CSV file and analyze the billing details for storage.
    2. View the records whose MeteringType is set to Storage. A total of 333,507,833,900 bytes of data is stored for the alian project. The data is uploaded at 08:00. Therefore, storage is billed from 09:07 and you are charged for 15-hour storage.
      Note If the billing cycle is one day, the billing stops at the end of each day. Therefore, the last record is not included in the bill of that day.
      You must calculate the average storage over the last 24 hours based on the billing rules described in Storage pricing (pay-as-you-go). Then, calculate the cost for storage.
      -- Calculate the average storage. 
      333507833900 Byte×15/1024/1024/1024/24=194.127109076362103 GB
      
      -- The data size is 194 GB. The storage unit price for the range of greater than 1 GB but less than 100 GB is USD 0.0028 per GB per day. The storage unit price for the range of greater than 100 GB but less than 1 TB is USD 0.0014 per GB per day. Therefore, the storage cost per day is calculated by using the following formula with four decimal places: 
      100 GB × USD 0.0028/GB-day + (194.127109076362103 GB - 100 GB) × USD 0.0014/GB-day = USD 0.4118/day