为什么 docker 会看到容器达到了 rss 限制?

Mik*_*ert 5 memory google-compute-engine docker

我试图了解为什么限制决定需要终止任务,以及它是如何进行会计处理的。当我的 GCE Docker 容器杀死一个进程时,它会显示如下内容:

Task in /404daacfcf6b9e55f71b3d7cac358f0dc921a2d580eed460c2826aea8e43f05e killed as a result of limit of /404daacfcf6b9e55f71b3d7cac358f0dc921a2d580eed460c2826aea8e43f05e 
memory: usage 2097152kB, limit 2097152kB, failcnt 74571 
memory+swap: usage 0kB, limit 18014398509481983kB, failcnt 0 
kmem: usage 0kB, limit 18014398509481983kB, failcnt 0 
Memory cgroup stats for /404daacfcf6b9e55f71b3d7cac358f0dc921a2d580eed460c2826aea8e43f05e: cache:368KB rss:2096784KB rss_huge:0KB mapped_file:0KB writeback:0KB inactive_anon:16KB active_anon:2097040KB inactive_file:60KB active_file:36KB unevictable:0KB 
[ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name 
[ 4343]     0  4343     5440       65      15        0             0 bash 
[ 4421]     0  4421   265895     6702      77        0             0 npm 
[ 4422]     0  4422    12446     2988      28        0             0 gunicorn 
[ 4557]     0  4557   739241   346035    1048        0             0 gunicorn 
[ 4560]     0  4560     1086       24       8        0             0 sh 
[ 4561]     0  4561     5466      103      15        0             0 bash 
[14594]     0 14594   387558   168790     672        0             0 node 
Memory cgroup out of memory: Kill process 4557 (gunicorn) score 662 or sacrifice child 
Killed process 4557 (gunicorn) total-vm:2956964kB, anon-rss:1384140kB, file-rss:0kB 
Run Code Online (Sandbox Code Playgroud)

据说内存达到了 2GB 的使用限制,有些东西需要消亡。根据 cgroup 统计数据,我在active_anon和 中似乎有 2GB 的使用量rss

当我查看进程统计表时,我没有看到 2GB 在哪里:

对于rss,我看到的两个主要过程346035 + 168790 = 514MB?对于total_vm,我看三大流程265895 + 739241 + 387558 = 1.4GB

但是当它决定终止 gunicorn 进程时,它说它有 3GB 的总 VM 和 1.4GB 的 Anon RSS。我根本看不出上面的数字是如何得出的......

对于大多数它的生活,根据top,该gunicorn过程似乎哼沿555m RES,并2131m VIRT22% MEM * 2.5GB box = 550MB内存的使用。(我还没有能够正确计时以查看top它死亡时的值......)

  • 有人可以帮助我理解这一点吗?
  • 在什么核算下,这些总和为 2GB 的使用量?(虚拟?rss?别的什么?)
  • 除了top/ps我应该使用其他东西来跟踪进程使用多少内存用于 docker 杀死它?

小智 0

据我所知,total_vm和rss的单位是4kB(参考: https: //stackoverflow.com/a/43611576),而不是kB。

因此对于 pid<4557>:

  • rss=346035,表示匿名rss:1384140kB (=346035*4kB)
  • Total_vm=739241,表示total-vm:2956964kB(=739241*4kB)

这将很好地解释你的内存使用情况。