最近遇到一个棘手的问题,部署在 docker 中的应用内存最近出现上升的情况,以至于需要不断重启应用来降低内存,容器内存变化如下图所示。
当容器内存升高时,Nginx 进程占用的内存确实是上升了。通过top命令查看的结果如下:
[admin@b64ba8a2-653a-4308-8da5-a355841d7f12 ~]$ top -d 20
top - 17:47:54 up 219 days, 14:38, 0 users, load average: 7.41, 4.89, 4.54
Tasks: 21 total, 1 running, 20 sleeping, 0 stopped, 0 zombie
%Cpu(s): 1.6 us, 2.2 sy, 0.0 ni, 96.0 id, 0.0 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 26386179+total, 11119760+free, 63156648 used, 89507552 buff/cache
KiB Swap: 16777212 total, 15732328 free, 1044884 used. 17263196+avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
106165 admin 20 0 87572 32280 2416 S 46.7 0.0 91:08.78 nginx
106158 admin 20 0 55720 1548 344 S 0.0 0.0 0:00.00 nginx
106159 admin 20 0 86948 32680 2416 S 0.0 0.0 108:34.85 nginx
106160 admin 20 0 90740 32668 2416 S 0.0 0.0 88:54.68 nginx
106161 admin 20 0 1810920 1.671g 2420 S 0.0 0.7 98:25.20 nginx
106162 admin 20 0 86548 32280 2416 S 0.0 0.0 102:32.22 nginx
106163 admin 20 0 1696468 1.560g 2420 S 0.0 0.6 100:02.93 nginx
106164 admin 20 0 86932 32696 2416 S 0.0 0.0 97:14.18 nginx
106166 admin 20 0 1463116 1.339g 2412 S 0.0 0.5 131:19.57 nginx