...
/Measuring Containers Memory and CPU Usage
Measuring Containers Memory and CPU Usage
In this lesson, we will see how to measure memory and CPU usage of an individual container.
Observe metrics over time #
If you are familiar with Kubernetes, you understand the importance of defining resource requests and limits. Since we already explored kubectl top pods
command, you might have set the requested resources to match the current usage, and you might have defined the limits to be above the requests. That approach might work on the first day. But, with time, those numbers will change, and we will not be able to get the full picture through kubectl top pods
. We need to know how much memory and CPU containers use when on their peak loads and how much they use when they are under less stress. We should observe those metrics over time and adjust periodically.
Even if we do somehow manage to guess how much memory and CPU a container needs, those numbers might change from one release to another. Maybe we introduced a feature that requires more memory or CPU?
What we need is to observe resource usage over time and make sure that it does not change with new releases or with increased (or decreased) numbers of users. For now, we’ll focus on the former case and explore how to see how much memory and CPU our ...