Pods are the smallest deployable units in ACK clusters and a key cost factor, but their varying resource configurations, scheduling policies, and lifecycles make cost estimation complex. ACK provides a general cost data model and calculation method to accurately measure cluster costs and allocate them to business units.
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 share of the cluster asset cost that is proportionally allocated to the allocated space in the cluster. |
idle cluster cost | The share of the cluster asset cost that is proportionally allocated to the unallocated space in the cluster. |
allocated pod cost | The amount of the cluster asset cost that is allocated to a pod within a specific period. |
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 determined by pod cost allocation. It is the sum of the costs allocated to all pods in the cluster and represents the portion of the cluster asset cost that has been allocated:
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, load balancers, and disks. It can also include optional cloud resources, such as Prometheus and NAT gateways. 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 split out all bills for the cloud resources associated with the cluster. The sum of these bills is the cluster asset cost.Cloud resources not automatically created by the cluster: Manually add the cluster ID resource tag to these cloud resources to include them in the cluster asset cost calculation.
Allocated pod cost
Calculation formula
Pods are usually not billed directly. To aggregate business bills accurately across different dimensions of the cluster, you must calculate the allocated cost of each pod proportionally from the cluster asset cost. Therefore, the key to calculating the allocated pod cost is to determine the pod 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. To calculate the simulated pod unit price, you must consider the allocated amount of each resource on 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. Obtain the unit price directly from your cloud provider (known resource unit price), or 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 must use a weighted allocation model for the calculation. The weighted allocation method provides more flexibility for model customization. In this model, the resource weight is the key factor that determines the value of a resource.
Unit price of a pod's compute resource = Resource weight * Node unit price / Total resources of the node
Σ (Resource weight) = 1
By default, ACK uses the resource scheduling watermark to determine how "expensive" a resource is in the cluster. This means that the recommended weight of a resource is determined by the proportion of its resource scheduling watermark. The weight value can also be customized based on your actual requirements.
Costs of namespaces and applications
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 an aggregation of pods that have the same field.
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
-
Retrieve cost insights data via API for custom development. See Call an API to query cost data.
-
You can estimate pod costs based on cluster resource utilization by using single-resource (CPU or memory) or weighted (CPU and memory) models. For more information, see Cost estimation policies.