DEV Community

Cover image for Tracking the efficiency of resource requests on Kubernetes
Rodrigue Chakode
Rodrigue Chakode

Posted on

Tracking the efficiency of resource requests on Kubernetes

Problem Context

Best practices on Kubernetes recommend setting resource requests (and also limits?) on workloads. It's even possible to set cluster-level policies to reject manifests without resource requests. However, one of the problems that this raises is the ability to suitably assess and set resource requests in a way that avoids wasting resources due to unused requested (i.e. reserved) capacities.

So, how to measure the efficiency of resource requests set on your Kubernetes workloads to avoid wasting resources due to oversized requested (i.e. reserved) capacities?

Our Original Contribution

Thanks to kube-opex-analytics, an open source Kubernetes usage analytics and accounting tool (read more about it at the end of this story), we address the problem of assessing the efficiency of resource requests set on Kubernetes workloads.
The release v22.02.0 introduces a new indicator called ๐”๐ฌ๐š๐ ๐ž/๐‘๐ž๐ช๐ฎ๐ž๐ฌ๐ญ ๐„๐Ÿ๐Ÿ๐ข๐œ๐ข๐ž๐ง๐œ๐ฒ. Conceptually, this indicator is defined as the ratio between the actual usage and the resource requests. The indicator is provided by namespace and, as all other kube-opex-analytics indicators, it's computed based on hourly-consolidated Kubernetes metrics.

By tracking and visualizing the usage/request efficiency indicator over time, Kubernetes administrators do have an additional tool to take appropriate cost-optimization decisions.

kube-opex-analytics :: Usage/Request Efficiency chartkube-opex-analyticsโ€Š-โ€ŠA chart showing the usage/request efficiency for CPU (1) and memory (2) resources for a selectable period of time (4). At specific date time, a tooltip (3) provides details for each namespace. It's possible to export (5) the chart as PNG image or as CSV and JSON dataย file.

The next section discusses possible values of this indicator.

Understanding Usage/Request Efficiency

At a given namespace and a given time, the value of this indicator can be in one of the following ranges:

  • A value equal to 1 means an effective match between the actual usage and requests; this is also the default value if no resource requests are set in the namespace.

  • A value between 0 (excluded) and 1 does mean that the actual usage is lower than resource requests. A value close to zero typically means that requests are oversized, and that they need to be reviewed to avoid wasting resources.

  • A value greater than 1 means that the actual usage is greater than the requests. It's likely an ideal situation to avoid wasting resources. However, in this case it's likely necessary to have resource limits or namespace quotas set to be sure that the resource consumption will be under control.

About kube-opex-analytics

kube-opex-analytics (literally Kubernetes Opex Analytics) is an open source Kubernetes usage analytics tool to help organizations track the resources being consumed by their Kubernetes clusters over time (hourly, daily, monthly). Doing so, kube-opex-analytics aims to prevent overpaying by enabling each organization to understand how their Kubernetes resources are consumed over time, and hence be able to make appropriate cost optimization decisions.

Some of its key features include:

  • Usage accounting and trends per namespace.
  • Accounting of non-allocatable capacities(nodes and cluster levels).
  • Cluster usage accounting and capacity planning.
  • Usage/requests efficiency.
  • Cost allocation and chargeback analytics.
  • Insightful and extensible visualization.

You can get additional information on kube-opex-analytics via its GitHub page.

Conclusion

In this story we have presented an original indicator to track the efficiency of resource requests set on Kubernetes workloads. The aim of this indicator is to provide Kubernetes administrators a tool to make appropriate cost-optimization decisions.

Don't hesitate to share your feedback.

Top comments (0)