【发布时间】:2021-03-30 14:33:36
【问题描述】:
我正在尝试找出并了解 OOM-killer 在容器上的工作原理。
为了弄清楚这一点,我阅读了很多文章,我发现 OOM-killer 会根据 oom_score 杀死容器。而oom_score 由oom_score_adj 和该进程的内存使用情况决定。
还有来自 cAdvisor 的两个指标 container_memory_working_set_bytes、container_memory_rss 用于监控容器的内存使用情况。
似乎 RSS 内存 (container_memory_rss) 对 oom_score 有影响,所以我可以理解,使用 container_memory_rss 指标,如果该指标达到内存限制,OOM-killer 将终止进程。
- https://github.com/torvalds/linux/blob/v3.10/fs/proc/base.c#L439
- https://github.com/torvalds/linux/blob/v3.10/mm/oom_kill.c#L141
- https://github.com/torvalds/linux/blob/v3.10/include/linux/mm.h#L1136
但是从下面的文章来看:
- https://faun.pub/how-much-is-too-much-the-linux-oomkiller-and-used-memory-d32186f29c9d
- https://blog.freshtracks.io/a-deep-dive-into-kubernetes-metrics-part-3-container-resource-metrics-361c5ee46e66
更好的指标是
container_memory_working_set_bytes,因为这是 OOM 杀手所关注的。
我无法理解 OOM-killer 正在监视容器的工作集内存这一事实。我想我不明白容器上的工作集内存的含义,即“总使用量 -非活动文件”。
在哪里可以找到参考资料?或者你能解释一下工作集内存和容器上的OOM-kill之间的关系吗?
【问题讨论】:
标签: linux kubernetes memory containers