I'm trying to find out and understand how OOM-killer works on the container.
To figuring it out, I've read lots of articles and I found out that OOM-killer kills container based on the oom_score. And oom_score is determined by oom_score_adj and memory usage of that process.
And there're two metrics container_memory_working_set_bytes, container_memory_rss from the cAdvisor for monitoring memory usage of the container.
It seems that RSS memory (container_memory_rss) has impact on oom_score so I can understand that with the container_memory_rss metric, if that metric reached to memory limit, the OOM-killer will kill the process.
- 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
But from the articles like below:
- 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
The better metric is
container_memory_working_set_bytesas this is what the OOM killer is watching for.
I cannot understand the fact that OOM-killer is watching for container's working set memory. I think I'm not understand the meaning of the working set memory on the container which is 'total usage - inactive file'.
Where can I find the reference? Or could you explain the relationship between working set memory and OOM-kill on the container?