Unit Cost for Kubernetes
Last updated
Last updated
Kubernetes is undoubtedly one of the most popular choices for modern SaaS architecture. Therefore, finding out the usage-based cost for running Kubernetes for SaaS customers is a commonly requested task by many SaaS business. There are different ways to run SaaS applications in Kubernetes. In this use case, we are exploring a multi-tenant deployment in Kubernetes while each tenant occupies one or more pods in a node. The diagram below illustrates the example topology for such a Kubernetes cluster.
Kubernetes can be hosted in different environments as well. In this use case study, we are exemplifying with AWS Elastic Kubernetes Service (EKS) hosted on AWS EC2 Instances. The usage-based cost calculation differs as the hosting environment differs. Paigo supports usage-based cost for various hosting environments.
The cost of running EKS on EC2 has several components. There are platform fees of EKS based on usage (see EKS Pricing), and there are EC2 costs (see EC2 Pricing). And there is potentially some other factors in the mix influencing the usage-based cost such as different types of EC2 instances including on-demand instances and reserved instances.
A good unit economy framework for the topology described above would be pod running time based given the single occupancy in Kubernetes pods. The running time example we are using here is Hour, meaning serving 1 hour of running time to a SaaS customer. There potentially could also be different ways of defining unit economy such as Minute or even Million Seconds. However, they should essentially represent the same idea and can be transformed from Hour back and forth.
Also note the unit economy is different for different configurations of Kubernetes pods. In other words, the hourly unit cost should be considered differently for a pod of 4 cores and a pod of 2 cores.
Paigo treats different configurations of Kubernetes pods differently, take into account the number of cores and the amount of memory. At a regular interval, Paigo samples all of the actively running pods by SaaS customers in Kubernetes clusters. Then Paigo calculates the hourly costs of those pods and save those data points in the backend journal as the raw data. Finally, Paigo runs batch analytics on the giant raw data set to group them by different configurations and calculate the average of each group. See below table for a sample result.
2
8
$0.01
4
16
$0.02
8
32
$0.03
When calculating the hourly cost of running pods, Paigo also takes into account the real cost of running underlying EC2 resources such as on-demand instances or reserved instances.
To enable the usage-based cost for EKS on EC2, it is recommended to enable Agent-based Method usage measurement and collection.
The usage-based cost can be leveraged to benchmark the pricing strategy. For example, one of the common ways is to define a pay-as-you-go pricing Product Items that allows customers to pay for the exact time of their usage, such as in CI/CD SaaS platforms. Knowing the unit cost of serving an hour of running time can help to define a price with a desired margin. Another example would be combining running time into a subscription tier Product Plans with other usage Dimension such as Storage. An Enterprise subscription tier may include 100 hours of running time per month.
Similar use cases can be applied to derive the usage-based cost of running GPUs in Kubernetes for machine learning platforms.