All Products
Search
Document Center

Container Service for Kubernetes:Overview of cost insights

Last Updated:Jul 03, 2023

The cost insights module of Container Service for Kubernetes (ACK) can help IT administrators analyze resource usage and allocate costs from multiple dimensions. This module offers suggestions on cost savings and helps improve resource utilization. The cost insights module can check for resource waste and evaluate resource costs. This module accurately calculates the average cost of a pod by analyzing bills, collecting resources usage statistics, and performing real-time inquiries. Cost insights allow you to use application labels, namespaces, and clusters to perform aggregate analysis from the logical dimension. Cost insights also allow you to use node pools and clusters to perform aggregate analysis from the resource dimension. This topic describes the cost insights module of ACK and the features that this module provides.

Background information

A large number of enterprises use cloud-native technologies for IT transformation in which costs optimization is an important objective. You can use the sharing, isolation, and elasticity capabilities of cloud-native technologies to optimize the costs in a simplified manner. Compared with the traditional capacity planning method that is used to manage IT costs, cloud-native technologies pose more challenges. The following section describes the most common problems:

  • How to accurately calculate the cost of an ACK cluster?

  • How to accurately calculate the average cost of a pod?

  • How to accurately calculate the average cost of an online application or a CronJob?

  • How to allocate the cost of ACK cluster management among different departments by using namespaces?

  • How to identify and optimize cost waste on a cluster in a visualized manner?

Figure 1. Resource utilizations of different types of clusters集群利用率

How cost insights work

  • How to accurately calculate the cost of an ACK cluster by using cost insights?

    The cost insights module of ACK adds the cluster ID as a unique label to the cloud resources that are deployed in a Kubernetes cluster. These resources include Elastic Compute Service (ECS) instances, Server Load Balancer (SLB) instances, Alibaba Cloud disks, elastic IP addresses (EIPs), and elastic container instances. After a bill is generated in the Billing Management console, you can use the cluster ID label to check the relationship between the resources and the cluster.

  • How to accurately calculate the average cost of a pod by using cost insights?

    The following problems exist when you calculate the average cost of a pod:

    • The billable items of nodes and pods are different. The cost of a pod varies based on the type of node on which the pod runs.

    • The lifecycles and billing cycles of cloud resources and pods are not the same. In most cases, the billing cycles of pods are shorter than the billing cycles of cloud resources.

    • The billable items of different types of pods vary because these pods may require different types of computing resources. In most cases, pods require CPU, memory, and GPU resources.

    To resolve the preceding problems, the cost insights module of ACK analyzes historical bills and calculates real-time costs to calculate the average cost of a pod. To accurately calculate the average cost of a pod, the cost insights module must first calculate the ratio of the real-time cost of a pod to the real-time cost of all pods. The real-time cost of a pod is calculated based on the following formula: Real-time cost of a pod = Unit price of core hours of the node on which the pod runs × Duration of the pod × Amount of CPU, memory, and GPU resources requested by the pod. Then, the cost insights module calculates the ratio based on the following formula: Cost ratio = Real-time cost of a pod/Real-time cost of all pods. Finally, the cost insights module calculates the average cost of a pod based on the following formula: Average cost of a pod = Cost ratio × Total amount of payments in all bills that were generated within the specified time period.

    Note

    In most cases, the bills of subscription resources are generated on a monthly basis. The bills of pay-as-you-go resources are generated on a daily basis. The unit price of preemptible instances changes every 5 minutes. Fees that are offset by using reserved instances, savings plans, and coupons are not included in bills. Therefore, the cost insights module must use the preceding method to calculate the average cost of a pod.

  • How to accurately calculate the average cost of an online application or a CronJob by using cost insights?

    The cost insights module of ACK splits and calculates costs based on labels. This allows you to aggregate and split application costs from every dimension by using labels. Cost insights solve the problem that the lifecycles of pods that are provisioned for different types of Jobs are different. The lifecycles of pods for online applications are longer and pods may be created or deleted due to scaling activities. The lifecycles of pods for CronJobs are shorter. Applications that use different architectures may run in pods that assume different roles, such as Spark Driver and Executor. The system may also deploy a large amount of dynamic resources for these applications, such as Elastic Compute Service (ECS) instances and elastic container instances.

  • How to use namespaces to allocate the cost of ACK cluster management among departments by using cost insights?

    A namespace is a group of pods that have one or more fields in common. After the cost insights module calculates the cost ratio of each pod, the module calculates the average cost of pods in a namespace based on the following formula: Average cost of pods in a namespace = Total cost of all pods in the namespace/Total cost of all pods in the cluster × Total amount of all payments in the bills of the cluster.

  • How to identify and optimize the cost waste on a cluster in a visualized manner?

    Cost waste is generated due to the following reasons: improper resource request settings, improper optimization of resource billing methods, and improper use of pod scheduling policies or auto scaling policies. The cost insights module of ACK provides suggestions on cost analysis, cost prediction, and cost savings based on the topology of cloud resources and pods, real-time unit prices, and bills to help you avoid cost waste.

Features

The cost insights module of ACK provides the following features:

  • Cost insights of cloud resources

    Aggregates the costs of all cloud resources within a Kubernetes cluster. Compares the cost of the previous day with that of the same date of the previous year. Compares the cost of the previous day with that of the day before the previous day.

  • Cost trend analysis of cloud resources

    Analyzes the cost trends of all cloud resources. Lists cloud resources with the highest cost contributions. This provides information that helps you reduce costs.

  • Suggestions on cost savings

    Analyzes the cost trend of a Kubernetes cluster. Provides correlation analysis between resource usage and cost contribution. Provides suggestions on how to reduce costs.

  • Real-time cost evaluation

    Simulates cost calculation based on the real-time prices of all computing resources within a cluster. Provides hourly cost evaluation. Multiple billing methods, such as subscription, pay-as-you-go, and preemptible instances, are supported.

  • Cost allocation based on namespaces

    Allocates the cost of a cluster based on namespaces. Provides real-time cost evaluation, cost trend, and cost contribution per namespace.

  • Optimization of application costs

    Lists the top 10 applications with the highest cost contributions. Provides the cost trends of the top 10 applications. This provides information that helps you improve the cost-effectiveness of an application.