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

Go to Billing Management

Log on to the Alibaba Cloud Management Console. In the top navigation bar, click Expenses. Expenses
Note If you log on to the console as a RAM user, you must obtain the AliyunBSSFullAccess permission. For more information, see Grant permissions to a RAM role.

View billing details

  • Query daily bills.
    1. On the Bills page, click the Bills tab.
    2. Select MaxCompute from the Product Name drop-down list 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 generated for the pay-as-you-go resource packages of MaxCompute on the day. The storage resources, computing resources, and the traffic for Internet-based data downloads in these packages are charged 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 generated for the subscription resource packages of MaxCompute on the day. The storage resources and the traffic for Internet-based data downloads in these packages are charged based on the pay-as-you-go billing method.
      • MaxCompute (Subscription) with Subscription Type set to Subscription: all subscription bills generated for the subscription resource packages of MaxCompute on the day. All new purchases, configuration upgrades and downgrades, and package renewals are charged 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. Set Statistic Item to Billing Item, Statistic Period to By Day, and Subscription Type to Pay-As-You-Go.
    3. Select MaxCompute from the Product Name drop-down list 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 current 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 set Statistic Item and Statistic Period to other values 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 computer 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 check the daily resource usage and how costs are calculated. 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 that you want to query. You can specify the start time and end time of the bills you want to view.

    If a job spans two days, for example, from December 1 to December 2, you must set December 1 as the start time. Otherwise, you cannot find the job in the downloaded usage records. However, the consumption record of the job is displayed in the bill for December 2.

Use usage records

After you export usage records to your computer as a CSV file, use Microsoft Excel to open the file and view the detailed information. The following code 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,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 running information of a specific job. For more information, see Information Schema. However, the views provide the running information only for the last 15 days.
  • Understand the original metering information of each SQL or MapReduce job and calculate the cost of the job based on the formula 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 unit price.
    • Calculate the costs of SQL jobs that involve external tables, such as tables in Tablestore or Object Storage Service (OSS). 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 that involves 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 typical scenarios

  • The costs surge beyond expectations.
    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, set Statistic Item to Instance and Statistic Period to By Day. 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, set Statistic Item to Billing Item and Statistic Period to By Day. 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 the computing jobs that generate high costs: If the preceding analysis indicates a surge in the costs of SQL computing jobs, download usage records. Then, analyze the records for which 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 = Amount of input data (bytes)/1024/1024/1024 × SQL complexity × SQL unit price. If the cost of an SQL job is higher than expected, we recommend that you check the ID of the DataWorks node on which the job runs based on the metering information.
      • If the ID is available, view the running 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 running details of the job by using TASKS_HISTORY based on the SQL billing code indicated by Instance ID.
        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 Configure 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