Updated on 2024-07-05 GMT+08:00

Cost Calculation Model

Workload Cost Calculation Principle

The costs of a workload are the total costs of all pods for running that workload.

  • Pod costs are calculated based on the percentage of total node resources (CPU and memory) that are used by a pod, plus the cost of PVC storage used by that pod.

    The requested CPU and the actual CPU are compared, and the larger value is used to calculate the cost.

    Figure 1 Workload cost calculation principle

    For example, at sampling point 1, the value of requested CPU is larger than that of actual CPU, the requested CPU is used for calculation.

    At sampling point is 2, the value of requested CPU is less than that of actual CPU, the actual CPU is used for calculation.

  • The costs of a workload are the total costs of all pods for running that workload.

Namespace Cost Calculation Principle

The costs of a namespace are the total costs of all workloads in that namespace.

Department Cost Calculation Principle

Departments are logical cost units used to aggregate and analyze the costs of different clusters and namespaces. Generally, actual business departments are used and associated with the clusters or namespaces they used.

The costs of a single cluster consist of the namespace cost, unallocated cost, and cluster management cost (the cost for managing master nodes in a CCE cluster and the system namespace). The unallocated cost and cluster management cost are defined as shared costs. If departments are set by namespace, the departments need to be associated with the namespaces, and the proportion of shared costs needs to be specified.

Figure 2 Department cost calculation example

Cluster 1 is a dedicated cluster of department A, cluster 2 is a dedicated cluster of department C, and cluster 3 is shared by departments A and C. Namespace 1 belongs to department A, and namespace 2 belongs to department C. When calculating the costs of each department, you can allocate the costs by namespace or cluster, specify the proportion of the shared costs generated in cluster 3 for department A and department C.

Common Issues During Calculation

  • Are the costs of a pod calculated from the requested resources or actually-used resources? Since resource metric values like used CPU and memory change dynamically, how can the costs of a pod be estimated accurately?

    The requested CPU and the actual CPU are compared, and the larger value is used to calculate the cost. As long as an application runs for more than 1 minute, its metrics can be collected by the prometheus add-on for cost calculation.

  • How are unallocated costs of a node handled?

    Unallocated costs of a node are not allocated as the workload or namespace costs, but can be shared among departments. You can specify the proportion of unallocated costs allocated to each department.