[英]Kubernetes Pod reporting more memory usage than actual process consumption
I have a Kubernetes Pod that has我有一个 Kubernetes Pod
I have 2 containers running inside this pod, one is the actual application (heavy Java app) and a lightweight log shipper.我在这个 pod 中运行了 2 个容器,一个是实际应用程序(重型 Java 应用程序)和一个轻量级日志传送器。
The pod consistently reports a usage of 1.9-2Gb of memory usage. pod 始终报告 1.9-2Gb 的内存使用情况。 Because of this, the deployment is scaled (an autoscaling configuration is set which scales pods if memory consumption > 80%), naturally resulting in more pods and more costs因此,部署是扩展的(设置了自动扩展配置,如果内存消耗 > 80% 则扩展 Pod),自然会导致更多的 Pod 和更多的成本
Yellow Line represents application memory usage黄线代表应用程序内存使用情况
However, on deeper investigation, this is what I found.然而,在更深入的调查中,这就是我发现的。
On exec
ing inside the application container, I ran the top
command, and it reports a total of 16431508 KiB
or roughly 16Gb of memory available, which is the memory available on the Machine.在应用程序容器内exec
,我运行了top
命令,它报告总共有16431508 KiB
或大约 16Gb 的可用内存,这是机器上可用的内存。
There are 3 processes running inside the application container, out of which the root process (application) takes 5.9% of memory, which roughly comes out to 0.92Gb.应用程序容器内运行着3个进程,其中根进程(应用程序)占用内存的5.9% ,大致为0.92Gb。
The log-shipper simply takes 6Mb of memory.日志传送器只需要 6Mb 的内存。
Now, what I don't understand is WHY my pod consistently reports such high usage metrics.现在,我不明白为什么我的 pod 总是报告如此高的使用指标。 Am I missing something ?我错过了什么吗? We're incurring significant costs due to the unintended auto-scaling and would like to fix the same.由于意外的自动缩放,我们产生了大量成本,并希望解决此问题。
In Linux unused memory considered as wasted memory, that's why all "free" RAM ie memory not used by application or kernel itself is actively used for caching IO operations, file system metadata, etc. but would be provided to your application if required.在 Linux 中,未使用的内存被视为浪费的内存,这就是为什么所有“空闲”RAM(即应用程序或内核本身未使用的内存)积极用于缓存 IO 操作、文件系统元数据等,但会在需要时提供给您的应用程序。
You can get detailed information about your container memory consumption in here:您可以在此处获取有关容器内存消耗的详细信息:
/sys/fs/cgroup/memory/docker/{id}/memory.stat /sys/fs/cgroup/memory/docker/{id}/memory.stat
If you want to scale your cluster based on memory usage it is better to count only your application size, not container memory usage.如果您想根据内存使用情况扩展集群,最好只计算应用程序大小,而不是容器内存使用情况。
如果有人在这里结束,请参阅此问题以了解有关使用kubectl top
与在容器内运行top
或free
的差异的更多信息: 检查 kubernetes pod CPU 和内存
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.