In an ACK cluster, a pod is the smallest deployable unit and a key factor for measuring cluster costs. However, because different pods can have different resource configurations, scheduling policies, and lifecycles, cost estimation is complex. ACK provides a general cost data model and calculation method to help you accurately measure the costs of your ACK clusters. You can then allocate these costs to business units across different dimensions, such as clusters, namespaces, and applications.
Key concepts
The following table describes the key concepts in this topic.
Concept | Description |
Total cluster cost | The total cost required to run an ACK cluster. |
Cluster asset cost | The sum of the bills for all cloud resources in a cluster. |
Indirect cluster cost | The extra fees or indirect overhead required to manage an ACK cluster, such as cluster management fees. |
Allocated cluster cost | The amount of cost allocated when the cluster asset cost is proportionally allocated to the used space in the cluster. |
Idle cluster cost | The amount of cost allocated when the cluster asset cost is proportionally allocated to the unused space in the cluster. |
Allocated pod cost | The amount of the cluster asset cost that is allocated to a pod within a specific epoch. |
The total cost of an ACK cluster includes the cluster asset cost and the indirect cluster cost: Total cluster cost = Cluster asset cost + Indirect cluster cost.
The cluster asset cost can be further divided into the allocated cluster cost and the idle cluster cost: Cluster asset cost = Allocated cluster cost + Idle cluster cost.
The allocated cluster cost is the sum of the costs allocated to all pods in the cluster. This value represents the portion of the cluster asset cost that has been allocated to pods: Allocated cluster cost = Σ (Allocated cost of each pod in the cluster)
The relationship is shown in the following figure.
Cost data model
Cluster asset cost
An ACK cluster usually contains basic cloud resources, such as nodes, Server Load Balancer (SLB) instances, and disks. It can also include optional cloud resources, such as Prometheus and NAT Gateway. The cluster asset cost is the sum of the bills for all cloud resources associated with the cluster.
Cloud resources automatically created by the cluster: In an ACK cluster, you can use the unique cluster ID tag (
ack.aliyun.com:<cluster-ID>) to identify all bills for the cloud resources associated with the cluster. The sum of these bills is the total asset cost of the cluster.Cloud resources not automatically created by the cluster: You can manually add the cluster ID tag to these cloud resources. This action includes them in the cluster asset cost calculation.
Allocated pod cost
Calculation formula
Pods are usually not billed directly. You need to calculate the allocated cost of each pod from the cluster asset cost. This lets you accurately aggregate business bills across different dimensions of the cluster. Therefore, the key to calculating the allocated cost of a pod is to determine the pod's cost percentage within the cluster.
Allocated pod cost = Pod cost percentage * Cluster asset cost
The pod cost percentage is the ratio of the simulated pod cost to the total cost to be allocated.
Pod cost percentage = Simulated pod cost / Total cost to be allocated
The simulated pod cost is determined by the simulated pod unit price and the duration. The simulated unit price of a pod is calculated based on the amount of each resource allocated to the pod, such as CPU, memory, and GPU, and the unit price of each resource.
Simulated pod cost = Simulated pod unit price * Duration
Simulated pod unit price = Σ (Resource unit price * Amount of allocated resource)
The resource unit price is the key factor that determines the pod cost. Different pricing methods can be used for different scenarios. You can obtain the unit price directly from your cloud provider (known resource unit price). You can also define a custom resource unit price (unknown resource unit price) for internal cost accounting.
Example 1: Known compute resource unit price
For example, in a common scenario where pod costs are estimated based on compute resources, you can use the following formulas to allocate pod costs:
Pod cost percentage = Simulated pod cost / Σ (Cost of each node in the cluster)
Simulated pod cost = (CPU unit price * Allocated CPU + Memory unit price * Allocated memory + GPU unit price * Allocated GPU) * Duration
Example 2: Unknown compute resource unit price
For scenarios where the unit price of compute resources is not directly provided, such as when Alibaba Cloud ECS provides only the total node price, you can use a weighted allocation model for the calculation. The weighted allocation method provides more flexibility for model customization.
Unit price of a pod's compute resource = Resource weight * Node unit price / Total resources of the node
Σ (Resource weight) = 1
In this case, the resource weight is the key factor that determines the value of a resource. By default, ACK uses the resource scheduling level to determine how "expensive" a resource is in the cluster. This means the recommended weight of a resource is determined by its resource scheduling level. You can also customize the weight value as needed.
Namespace and application costs
After you calculate the allocated pod cost as described in the preceding sections, you can aggregate the allocated pod costs to calculate the costs of namespaces and applications (workloads).
A namespace is a logical grouping of pods.
Namespace cost = Σ (Allocated cost of each pod in the namespace)
A workload is an aggregation of pods that have the same label within a namespace.
Workload cost = Σ (Allocated cost of pods with the same label)
References
You can send HTTP API requests to retrieve cost insights data and use the data for custom development. For more information, see Overview of calling an API to query cost data.
You can estimate the pod cost based on the resource watermark of the cluster. You can use single resource cost estimation (based on CPUs or memory) or weighted resource cost estimation (based on CPUs and memory). For more information, see Cost estimation policies.