Search⌘ K

Adjusting Resources Based on Actual Usage

Explore how to measure and adjust Kubernetes resource specifications based on actual application usage. Understand the limitations of test environments and stress testing, and learn to update resource requests and limits for better performance under production-like loads.

Getting the actual resource usage

We saw some of the effects that can be caused by a discrepancy between resource usage and resource specification. It’s only natural that we should adjust our specification to reflect the actual memory and CPU usage better.

The DB container

Let’s start with the database.

Shell
kubectl top pods

The output is as follows:

Shell
NAME CPU(cores) MEMORY(bytes)
go-demo-2-api-... 0m 4Mi
go-demo-2-api-... 0m 4Mi
go-demo-2-api-... 0m 4Mi
go-demo-2-db-... 4m 34Mi

As expected, an api container uses even fewer resources than MongoDB. Its memory is somewhere between 2Mi and 6Mi. Its CPU usage is so low that Metrics Server rounded it to 0m.

The memory usage resources may differ from the above-mentioned ...