nomad icon indicating copy to clipboard operation
nomad copied to clipboard

high memory usage in logmon

Open anastazya opened this issue 5 years ago • 55 comments

I have a cluster of 20 nodes, all running "raw-exec" tasks in PHP.

At random intervals after a while i get a lot of OOM's. I find the server with 100% swap usage and looking like this :

Screenshot 2021-01-20 at 17 45 21

If i restart the nomad agent, it all goes back to normal for a while.

I also get this in nomad log : "2021-01-20T17:52:28.522+0200 [INFO] client.gc: garbage collection skipped because no terminal allocations: reason="number of allocations (89) is over the limit (50)" <--- that message is extremely ambiguous as everything runs normal and nomad was just restarted.

anastazya avatar Jan 20 '21 16:01 anastazya

Hi @anastazya! The htop output you have there is displaying all the threads for the Nomad agent process (all the green-colored lines). So that PID 1146 has only ~1GB RSS. Can you provide the rest of the memory stats? ps -eo pid,tid,class,rtprio,stat,vsz,rss,comm will give a reasonable table of the whole host.

tgross avatar Jan 20 '21 16:01 tgross

ps -eo pid,tid,class,rtprio,stat,vsz,rss,comm

I can give the stats for another host in the same state, cause i restarted nomad on the host that i took the screenshot.

  PID   TID CLS RTPRIO STAT    VSZ   RSS COMMAND
    1     1 TS       - Ss    52876  4204 systemd
    2     2 TS       - S         0     0 kthreadd
    4     4 TS       - S<        0     0 kworker/0:0H
    6     6 TS       - S         0     0 ksoftirqd/0
    7     7 FF      99 S         0     0 migration/0
    8     8 TS       - S         0     0 rcu_bh
    9     9 TS       - S         0     0 rcu_sched
   10    10 TS       - S<        0     0 lru-add-drain
   11    11 FF      99 S         0     0 watchdog/0
   12    12 FF      99 S         0     0 watchdog/1
   13    13 FF      99 S         0     0 migration/1
   14    14 TS       - S         0     0 ksoftirqd/1
   16    16 TS       - S<        0     0 kworker/1:0H
   17    17 FF      99 S         0     0 watchdog/2
   18    18 FF      99 S         0     0 migration/2
   19    19 TS       - S         0     0 ksoftirqd/2
   21    21 TS       - S<        0     0 kworker/2:0H
   22    22 FF      99 S         0     0 watchdog/3
   23    23 FF      99 S         0     0 migration/3
   24    24 TS       - S         0     0 ksoftirqd/3
   26    26 TS       - S<        0     0 kworker/3:0H
   27    27 FF      99 S         0     0 watchdog/4
   28    28 FF      99 S         0     0 migration/4
   29    29 TS       - S         0     0 ksoftirqd/4
   31    31 TS       - S<        0     0 kworker/4:0H
   32    32 FF      99 S         0     0 watchdog/5
   33    33 FF      99 S         0     0 migration/5
   34    34 TS       - S         0     0 ksoftirqd/5
   36    36 TS       - S<        0     0 kworker/5:0H
   37    37 FF      99 S         0     0 watchdog/6
   38    38 FF      99 S         0     0 migration/6
   39    39 TS       - S         0     0 ksoftirqd/6
   41    41 TS       - S<        0     0 kworker/6:0H
   42    42 FF      99 S         0     0 watchdog/7
   43    43 FF      99 S         0     0 migration/7
   44    44 TS       - S         0     0 ksoftirqd/7
   46    46 TS       - S<        0     0 kworker/7:0H
   47    47 FF      99 S         0     0 watchdog/8
   48    48 FF      99 S         0     0 migration/8
   49    49 TS       - S         0     0 ksoftirqd/8
   51    51 TS       - S<        0     0 kworker/8:0H
   52    52 FF      99 S         0     0 watchdog/9
   53    53 FF      99 S         0     0 migration/9
   54    54 TS       - S         0     0 ksoftirqd/9
   56    56 TS       - S<        0     0 kworker/9:0H
   57    57 FF      99 S         0     0 watchdog/10
   58    58 FF      99 S         0     0 migration/10
   59    59 TS       - S         0     0 ksoftirqd/10
   61    61 TS       - S<        0     0 kworker/10:0H
   62    62 FF      99 S         0     0 watchdog/11
   63    63 FF      99 S         0     0 migration/11
   64    64 TS       - S         0     0 ksoftirqd/11
   66    66 TS       - S<        0     0 kworker/11:0H
   68    68 TS       - S         0     0 kdevtmpfs
   69    69 TS       - S<        0     0 netns
   70    70 TS       - S         0     0 khungtaskd
   71    71 TS       - S<        0     0 writeback
   72    72 TS       - S<        0     0 kintegrityd
   73    73 TS       - S<        0     0 bioset
   74    74 TS       - S<        0     0 bioset
   75    75 TS       - S<        0     0 bioset
   76    76 TS       - S<        0     0 kblockd
   77    77 TS       - S<        0     0 md
   78    78 TS       - S<        0     0 edac-poller
   79    79 TS       - S<        0     0 watchdogd
   85    85 TS       - S         0     0 kswapd0
   86    86 TS       - SN        0     0 ksmd
   87    87 TS       - SN        0     0 khugepaged
   88    88 TS       - S<        0     0 crypto
   96    96 TS       - S<        0     0 kthrotld
   98    98 TS       - S<        0     0 kmpath_rdacd
   99    99 TS       - S<        0     0 kaluad
  101   101 TS       - S<        0     0 kpsmoused
  102   102 TS       - S<        0     0 ipv6_addrconf
  115   115 TS       - S<        0     0 deferwq
  151   151 TS       - S         0     0 kauditd
  359   359 TS       - S<        0     0 ata_sff
  364   364 TS       - S         0     0 scsi_eh_0
  365   365 TS       - S<        0     0 scsi_tmf_0
  366   366 TS       - S         0     0 scsi_eh_1
  367   367 TS       - S<        0     0 scsi_tmf_1
  372   372 TS       - S<        0     0 ttm_swap
  378   378 TS       - S<        0     0 virtscsi-scan
  379   379 TS       - S         0     0 scsi_eh_2
  380   380 TS       - S<        0     0 scsi_tmf_2
  418   418 TS       - S<        0     0 kworker/0:1H
  459   459 TS       - S<        0     0 kdmflush
  460   460 TS       - S<        0     0 bioset
  469   469 TS       - S<        0     0 kdmflush
  470   470 TS       - S<        0     0 bioset
  485   485 TS       - S<        0     0 bioset
  486   486 TS       - S<        0     0 xfsalloc
  487   487 TS       - S<        0     0 xfs_mru_cache
  488   488 TS       - S<        0     0 xfs-buf/dm-0
  489   489 TS       - S<        0     0 xfs-data/dm-0
  490   490 TS       - S<        0     0 xfs-conv/dm-0
  491   491 TS       - S<        0     0 xfs-cil/dm-0
  492   492 TS       - S<        0     0 xfs-reclaim/dm-
  493   493 TS       - S<        0     0 xfs-log/dm-0
  494   494 TS       - S<        0     0 xfs-eofblocks/d
  495   495 TS       - S         0     0 xfsaild/dm-0
  577   577 TS       - Ss   240436 136660 systemd-journal
  597   597 TS       - Ss   198572   428 lvmetad
  613   613 TS       - Ss    44980   780 systemd-udevd
  660   660 TS       - S         0     0 hwrng
  669   669 TS       - S<        0     0 kworker/2:1H
  758   758 TS       - S         0     0 jbd2/sda1-8
  759   759 TS       - S<        0     0 ext4-rsv-conver
  780   780 TS       - S<sl  55532   812 auditd
  786   786 TS       - S<        0     0 rpciod
  787   787 TS       - S<        0     0 xprtiod
  810   810 TS       - Ss    69280   856 rpcbind
  811   811 TS       - Ss    21672   596 irqbalance
  812   812 TS       - Ssl  612364  8324 polkitd
  813   813 TS       - Ss    12032   320 statsd-aggregat
  814   814 TS       - Ss    58232  1468 dbus-daemon
  826   826 TS       - Ssl  195204   708 gssproxy
  834   834 TS       - Ss    44220  1448 qemu-ga
  853   853 TS       - Ss    26828  1664 systemd-logind
  858   858 TS       - Ss    47296  1480 ntpd
  880   880 TS       - Ssl  527804 15492 python
  885   885 TS       - Ss   126388  1028 crond
  994   994 TS       - S<        0     0 kworker/8:1H
 1001  1001 TS       - S<        0     0 kworker/9:1H
 1002  1002 TS       - S<        0     0 kworker/4:1H
 1057  1057 TS       - Ss   17253808 77440 php-fpm
 1059  1059 TS       - Ssl  716956 39420 mcollectived
 1063  1063 TS       - Ss   116740  2380 lldpd
 1066  1066 TS       - Ss   112924  2320 sshd
 1071  1071 TS       - Ssl  261420 48932 puppet
 1073  1073 TS       - S    116740  1412 lldpd
 1076  1076 TS       - Ssl  574300 12680 tuned
 1078  1078 TS       - Ssl  719924 22020 node_exporter
 1080  1080 TS       - Ssl  5099008 1507836 nomad
 1099  1099 TS       - SNl  4806612 391428 java
 1113  1113 TS       - Ssl  793528  3508 collectd
 1186  1186 TS       - Ssl  713480 72144 rsyslogd
 1212  1212 TS       - Ssl  321332 240152 consul-template
 1230  1230 TS       - Ssl  1415096 22308 containerd
 1256  1256 TS       - SNsl 117444  2468 osqueryd
 1282  1282 TS       - Ss    98408 15468 haproxy
 1314  1314 TS       - S    17253808 9048 php-fpm
 1315  1315 TS       - S    17253808 9048 php-fpm
 1318  1318 TS       - S    17253808 9048 php-fpm
 1322  1322 TS       - S    17253808 9048 php-fpm
 1324  1324 TS       - S    17253808 9052 php-fpm
 1330  1330 TS       - SNl  832772 20452 osqueryd
 1344  1344 TS       - Ss+  110204   300 agetty
 1528  1528 TS       - Ssl  1143392 50756 dockerd
 1658  1658 TS       - Ssl  134196 12244 unbound
 1666  1666 TS       - Ss    89708  1352 master
 1690  1690 TS       - S     89992  2100 qmgr
 1810  1810 TS       - S         0     0 kworker/10:1
 1821  1821 TS       - Sl   1692208 22136 sensu-client
 2248  2248 TS       - S<        0     0 kworker/1:1H
 2620  2620 TS       - Ssl  1672444 15528 nomad
 2645  2645 TS       - S    626840 84268 php
 3060  3060 TS       - Sl   1928244 132140 nomad
 3067  3067 TS       - Sl   1729264 66020 nomad
 3078  3078 TS       - Sl   1666356 135940 nomad
 3079  3079 TS       - Sl   1869568 332664 nomad
 3106  3106 TS       - Sl   1869312 324672 nomad
 3112  3112 TS       - Sl   1663728 65752 nomad
 3123  3123 TS       - Sl   1665844 142764 nomad
 3135  3135 TS       - Sl   1943300 323592 nomad
 3144  3144 TS       - Sl   1804288 320004 nomad
 3164  3164 TS       - Sl   1598448 69464 nomad
 3275  3275 TS       - Sl   1875392 254960 nomad
 3288  3288 TS       - Sl   1729264 70084 nomad
 3305  3305 TS       - Sl   1664048 70556 nomad
 3315  3315 TS       - Sl   1945640 424600 nomad
 3333  3333 TS       - Sl   1597680 71896 nomad
 3344  3344 TS       - Sl   2011176 421620 nomad
 3357  3357 TS       - Sl   1741092 418900 nomad
 3358  3358 TS       - Sl   1532976 69468 nomad
 3377  3377 TS       - Sl   1597680 83116 nomad
 3527  3527 TS       - Sl   1664048 68144 nomad
 3528  3528 TS       - Sl   1598192 65324 nomad
 3534  3534 TS       - Sl   1663728 72516 nomad
 3541  3541 TS       - Sl   1794544 76672 nomad
 3564  3564 TS       - Sl   1729072 79336 nomad
 3574  3574 TS       - Sl   1532976 65360 nomad
 3604  3604 TS       - Sl   1663728 81436 nomad
 3628  3628 TS       - Sl   1532720 74684 nomad
 3665  3665 TS       - Sl   1598192 86096 nomad
 3700  3700 TS       - Sl   1466864 62912 nomad
 3721  3721 TS       - Sl   1532400 63456 nomad
 3753  3753 TS       - Sl   1663728 80948 nomad
 3801  3801 TS       - Sl   1598448 75284 nomad
 3829  3829 TS       - Sl   1728496 84708 nomad
 3858  3858 TS       - Sl   1597936 71556 nomad
 3902  3902 TS       - Sl   1663472 89948 nomad
 3944  3944 TS       - Sl   1466608 61384 nomad
 3945  3945 TS       - Sl   1598192 67168 nomad
 3959  3959 TS       - Sl   1598192 64032 nomad
 4004  4004 TS       - Sl   1467376 77692 nomad
 4037  4037 TS       - Sl   1598192 79208 nomad
 4067  4067 TS       - Sl   1467376 69844 nomad
 4098  4098 TS       - Sl   1467120 77180 nomad
 4128  4128 TS       - Sl   1598448 67808 nomad
 4153  4153 TS       - Sl   1532912 64836 nomad
 4188  4188 TS       - Sl   1597680 69220 nomad
 4226  4226 TS       - Sl   1663472 83192 nomad
 4345  4345 TS       - Sl   1597936 60992 nomad
 4369  4369 TS       - Sl   1532656 80740 nomad
 4395  4395 TS       - Sl   1532656 68400 nomad
 4408  4408 TS       - Sl   1598448 61784 nomad
 4444  4444 TS       - Sl   1663792 78628 nomad
 4454  4454 TS       - Sl   1663984 70584 nomad
 4694  4694 TS       - S         0     0 kworker/4:0
 5642  5642 TS       - Ss   158928  5748 sshd
 5723  5723 TS       - Ss+  116472  3052 bash
 7355  7355 TS       - S<        0     0 kworker/3:1H
 7391  7391 TS       - Ssl  1532152 18224 nomad
 7402  7402 TS       - S    624668 88888 php
 7830  7830 TS       - S         0     0 kworker/u192:1
 7980  7980 TS       - S         0     0 kworker/10:2
 8084  8084 TS       - Sl   1595820 10828 nomad
 8441  8441 TS       - Ssl  1597944 18220 nomad
 8452  8452 TS       - S    533228 82400 php
 9335  9335 TS       - Ssl  1532152 18352 nomad
 9345  9345 TS       - S    552968 100960 php
 9714  9714 TS       - S<        0     0 kworker/7:1H
10637 10637 TS       - Ssl  1597944 17968 nomad
10652 10652 TS       - S    521780 70132 php
12436 12436 TS       - S         0     0 kworker/8:1
12490 12490 TS       - S         0     0 kworker/9:1
13161 13161 TS       - S         0     0 kworker/0:0
13252 13252 TS       - S         0     0 kworker/1:1
14079 14079 TS       - S<        0     0 kworker/11:1H
14947 14947 TS       - S         0     0 kworker/0:2
14955 14955 TS       - S<        0     0 kworker/6:1H
14979 14979 TS       - S         0     0 kworker/5:2
15116 15116 TS       - S         0     0 kworker/6:1
15737 15737 TS       - Ssl  1646832 17792 nomad
15747 15747 TS       - S    519732 68740 php
15755 15755 TS       - Ssl  1449968 17824 nomad
15774 15774 TS       - S    519732 68736 php
15803 15803 TS       - Ssl  1597944 18020 nomad
15813 15813 TS       - S    519744 68736 php
15815 15815 TS       - Ssl  1598200 18036 nomad
15825 15825 TS       - S    519732 68736 php
15963 15963 TS       - Ssl  1507052 17860 nomad
15974 15974 TS       - S    519732 68732 php
16056 16056 TS       - Ssl  1507564 18332 nomad
16067 16067 TS       - S    519732 68732 php
16116 16116 TS       - Ssl  1515248 17980 nomad
16126 16126 TS       - S    519732 68732 php
16133 16133 TS       - Ssl  1597176 17888 nomad
16144 16144 TS       - S    519744 68736 php
19972 19972 TS       - Ssl  1573100 18004 nomad
19982 19982 TS       - S    526196 73520 php
20260 20260 TS       - Ssl  1523956 18168 nomad
20271 20271 TS       - S    519732 68720 php
20277 20277 TS       - S         0     0 kworker/7:2
20278 20278 TS       - S         0     0 kworker/7:3
20279 20279 TS       - S         0     0 kworker/7:4
20280 20280 TS       - S         0     0 kworker/7:5
20281 20281 TS       - S         0     0 kworker/7:6
20282 20282 TS       - S         0     0 kworker/7:7
20283 20283 TS       - S         0     0 kworker/7:8
20284 20284 TS       - S         0     0 kworker/7:9
20285 20285 TS       - S         0     0 kworker/7:10
20286 20286 TS       - S         0     0 kworker/7:11
20287 20287 TS       - S         0     0 kworker/7:12
20288 20288 TS       - S         0     0 kworker/7:13
20289 20289 TS       - S         0     0 kworker/7:14
20290 20290 TS       - S         0     0 kworker/7:15
20291 20291 TS       - S         0     0 kworker/7:16
20292 20292 TS       - S         0     0 kworker/7:17
20293 20293 TS       - S         0     0 kworker/7:18
20294 20294 TS       - S         0     0 kworker/7:19
20295 20295 TS       - S         0     0 kworker/7:20
20296 20296 TS       - S         0     0 kworker/7:21
20297 20297 TS       - S         0     0 kworker/7:22
20298 20298 TS       - S         0     0 kworker/7:23
20299 20299 TS       - S         0     0 kworker/7:24
20300 20300 TS       - S         0     0 kworker/7:25
20301 20301 TS       - S         0     0 kworker/7:26
20302 20302 TS       - S         0     0 kworker/7:27
20303 20303 TS       - S         0     0 kworker/7:28
20304 20304 TS       - S         0     0 kworker/7:29
20305 20305 TS       - S         0     0 kworker/7:30
20306 20306 TS       - Ssl  1450224 18360 nomad
20316 20316 TS       - S    519732 68600 php
20318 20318 TS       - Ssl  1523956 18092 nomad
20328 20328 TS       - S    519732 68604 php
20330 20330 TS       - Ssl  1458932 17980 nomad
20337 20337 TS       - Ssl  1524212 18156 nomad
20346 20346 TS       - S    519744 68604 php
20351 20351 TS       - S    519744 68600 php
20424 20424 TS       - S         0     0 kworker/0:3
20425 20425 TS       - S         0     0 kworker/0:4
20426 20426 TS       - S         0     0 kworker/0:5
20427 20427 TS       - S         0     0 kworker/0:6
20428 20428 TS       - S         0     0 kworker/0:7
20429 20429 TS       - S         0     0 kworker/0:8
20430 20430 TS       - S         0     0 kworker/0:9
20432 20432 TS       - S         0     0 kworker/0:10
20433 20433 TS       - S         0     0 kworker/0:11
20434 20434 TS       - S         0     0 kworker/0:12
20435 20435 TS       - S         0     0 kworker/0:13
20437 20437 TS       - S         0     0 kworker/0:14
20438 20438 TS       - S         0     0 kworker/0:15
20440 20440 TS       - S         0     0 kworker/0:16
20441 20441 TS       - S         0     0 kworker/0:17
20442 20442 TS       - S         0     0 kworker/0:18
20443 20443 TS       - S         0     0 kworker/0:19
20446 20446 TS       - S         0     0 kworker/0:20
20461 20461 TS       - S         0     0 kworker/3:0
20483 20483 TS       - Ssl  1597688 18124 nomad
20493 20493 TS       - S    543012 90800 php
20660 20660 TS       - S         0     0 kworker/10:0
20661 20661 TS       - Ssl  1581040 18376 nomad
20671 20671 TS       - S    552692 100416 php
20673 20673 TS       - S         0     0 kworker/8:0
20805 20805 TS       - S<        0     0 kworker/10:1H
23052 23052 TS       - Ssl  1449968 17792 nomad
23064 23064 TS       - S    535252 83784 php
23200 23200 TS       - Ssl  1515760 17536 nomad
23212 23212 TS       - S    521784 69528 php
23633 23633 TS       - Ssl  1450224 17576 nomad
23644 23644 TS       - S    536956 85500 php
23713 23713 TS       - Ssl  1663992 18200 nomad
23723 23723 TS       - S    553080 101248 php
25207 25207 TS       - Ssl  1376492 17964 nomad
25218 25218 TS       - S    526004 72996 php
26538 26538 TS       - Ssl  1467128 18552 nomad
26550 26550 TS       - Ssl  1597688 18736 nomad
26562 26562 TS       - S    550208 98308 php
26568 26568 TS       - S    549868 98472 php
26583 26583 TS       - Ssl  1523700 17432 nomad
26593 26593 TS       - S    519732 68732 php
26640 26640 TS       - Ssl  1433576 17728 nomad
26651 26651 TS       - S    519732 68632 php
26680 26680 TS       - Ssl  1598200 18540 nomad
26690 26690 TS       - S    549624 98304 php
26692 26692 TS       - Ssl  1597944 18688 nomad
26703 26703 TS       - S    549884 97904 php
26784 26784 TS       - Ssl  1663736 18964 nomad
26795 26795 TS       - S    549836 98120 php
26837 26837 TS       - Ssl  1663736 18812 nomad
26848 26848 TS       - S    549648 97464 php
27156 27156 TS       - Ssl  1384432 18416 nomad
27173 27173 TS       - S    523428 72012 php
27694 27694 TS       - Sl   1456552 10712 nomad
27793 27793 TS       - Sl   1660908 10212 nomad
27898 27898 TS       - Ssl  1376236 17868 nomad
27909 27909 TS       - S    521780 69524 php
27946 27946 TS       - Sl   1522088 8816 nomad
28009 28009 TS       - Ssl  1441260 18060 nomad
28019 28019 TS       - S    521780 69524 php
28106 28106 TS       - Sl   1464492 8808 nomad
28130 28130 TS       - Sl   1661100 8676 nomad
28131 28131 TS       - Sl   1595884 10188 nomad
28400 28400 TS       - Sl   1660588 9776 nomad
29624 29624 TS       - S<        0     0 kworker/5:1H
29724 29724 TS       - Ssl  1597944 18808 nomad
29735 29735 TS       - S    553444 101292 php
30323 30323 TS       - Ss   158928  5696 sshd
30326 30326 TS       - D    159240  2600 sshd
30327 30327 TS       - Ss   116476  3024 bash
30532 30532 TS       - S    241328  4712 sudo
30533 30533 TS       - S    191876  2364 su
30534 30534 TS       - S    116492  3052 bash
30544 30544 TS       - Ssl  1597944 18120 nomad
30561 30561 TS       - S    536364 83904 php
31040 31040 TS       - Ssl  1062996 15036 nomad
31049 31049 TS       - Ssl  1128788 15360 nomad
31067 31067 TS       - S    521648 68732 php
31069 31069 TS       - S    521648 68732 php
31080 31080 TS       - Sl   1399212 9732 nomad
31090 31090 TS       - S    113280  1416 bash
31108 31108 TS       - Sl   785904 27808 consul
31119 31119 TS       - R+   153348  1504 ps
31692 31692 TS       - Sl   1399468 9276 nomad
31835 31835 TS       - Sl   1464748 10112 nomad
32327 32327 TS       - Ssl  1663480 19052 nomad
32338 32338 TS       - S    536452 85600 php
32378 32378 TS       - S         0     0 kworker/11:1
32978 32978 TS       - S         0     0 kworker/2:2
33060 33060 TS       - Sl   1398956 10128 nomad
33344 33344 TS       - Sl   1333164 10748 nomad
33367 33367 TS       - Sl   1399468 11320 nomad
34118 34118 TS       - Ssl  1532664 17568 nomad
34129 34129 TS       - S    521648 68736 php
34130 34130 TS       - Ssl  1532664 18948 nomad
34141 34141 TS       - S    521652 68740 php
35483 35483 TS       - Sl   1932732 241616 nomad
35501 35501 TS       - Sl   2002980 408460 nomad
35502 35502 TS       - Sl   1806628 407244 nomad
35504 35504 TS       - Sl   1814824 406064 nomad
35531 35531 TS       - Sl   1945896 411540 nomad
35553 35553 TS       - Sl   2002980 434228 nomad
35555 35555 TS       - Sl   1937700 418228 nomad
35565 35565 TS       - Sl   1806628 424916 nomad
35594 35594 TS       - Sl   1872164 428600 nomad
35599 35599 TS       - Sl   2011176 421008 nomad
35643 35643 TS       - Sl   1598512 65360 nomad
35672 35672 TS       - Sl   1532656 65568 nomad
35691 35691 TS       - Sl   1532464 64748 nomad
35693 35693 TS       - Sl   1729264 67460 nomad
35710 35710 TS       - Sl   1532464 66608 nomad
35778 35778 TS       - Sl   1729520 64968 nomad
35784 35784 TS       - Sl   1598000 66292 nomad
35791 35791 TS       - Sl   1663472 68904 nomad
35798 35798 TS       - Sl   1467120 66256 nomad
35831 35831 TS       - Sl   2002980 414260 nomad
35900 35900 TS       - Sl   1401392 71608 nomad
35912 35912 TS       - Sl   2002980 423752 nomad
35914 35914 TS       - Sl   1467120 66736 nomad
35931 35931 TS       - Sl   1597936 69128 nomad
35961 35961 TS       - Sl   1533232 78188 nomad
36011 36011 TS       - Sl   1598000 74420 nomad
36050 36050 TS       - Sl   1598192 64412 nomad
36727 36727 TS       - S         0     0 kworker/7:0
39137 39137 TS       - S         0     0 kworker/3:1
40264 40264 TS       - Ssl  1597944 18280 nomad
40274 40274 TS       - S    521648 68872 php
42031 42031 TS       - Ssl  1597944 18072 nomad
42042 42042 TS       - S    629892 101148 php
43813 43813 TS       - S         0     0 kworker/6:2
50847 50847 TS       - Ssl  1598200 18432 nomad
50858 50858 TS       - R    564072 112376 php
52182 52182 TS       - S         0     0 kworker/u192:2
52844 52844 TS       - Ssl  1794552 18264 nomad
52854 52854 TS       - S    521652 68760 php
53710 53710 TS       - Ssl  1598200 18836 nomad
53721 53721 TS       - S    611952 75528 php
54540 54540 TS       - Ssl  1729016 18196 nomad
54551 54551 TS       - S    521648 68744 php
56017 56017 TS       - S         0     0 kworker/1:0
56643 56643 TS       - Ssl  1663736 18328 nomad
56654 56654 TS       - S    550656 99024 php
56756 56756 TS       - Ssl  1597432 18024 nomad
56767 56767 TS       - S    521648 68740 php
58710 58710 TS       - Ssl  1598200 19424 nomad
58721 58721 TS       - S    626860 98992 php
58860 58860 TS       - Ssl  1532152 18212 nomad
58872 58872 TS       - S    521648 68840 php
59376 59376 TS       - Ssl  1532152 18200 nomad
59390 59390 TS       - S    521648 68840 php
59444 59444 TS       - Ssl  1466616 18264 nomad
59455 59455 TS       - S    521652 68840 php
60018 60018 TS       - S         0     0 kworker/4:2
60788 60788 TS       - Ssl  1597944 18004 nomad
60799 60799 TS       - S    521648 68736 php
61008 61008 TS       - Ssl  1729272 18008 nomad
61018 61018 TS       - S    521648 68736 php
61020 61020 TS       - Ssl  1663480 17980 nomad
61031 61031 TS       - S    521648 68736 php
63084 63084 TS       - S         0     0 kworker/2:0
63701 63701 TS       - S         0     0 kworker/5:1
64856 64856 TS       - Ssl  1466872 18104 nomad
64866 64866 TS       - S    609924 80952 php
64915 64915 TS       - Ssl  1532408 18484 nomad
64927 64927 TS       - S    609956 80868 php
64928 64928 TS       - Ssl  1605884 18184 nomad
64938 64938 TS       - S    609844 80724 php
65295 65295 TS       - Ssl  1729016 18196 nomad
65306 65306 TS       - S    522124 71028 php
66651 66651 TS       - Ssl  1531896 17784 nomad
66661 66661 TS       - S    523828 71376 php
67059 67059 TS       - Ssl  1401400 18216 nomad
67069 67069 TS       - S    523828 71376 php
67213 67213 TS       - Ssl  1597944 18120 nomad
67224 67224 TS       - S    582592 130464 php
73161 73161 TS       - Sl   912420 18708 haproxy
79202 79202 TS       - Ssl  1597944 18156 nomad
79213 79213 TS       - S    519732 68732 php
80194 80194 TS       - Ssl  1532920 18136 nomad
80204 80204 TS       - S    525876 73156 php
82688 82688 TS       - Ssl  1458676 18476 nomad
82699 82699 TS       - S    522380 71488 php
82845 82845 TS       - Ssl  1532152 17964 nomad
82855 82855 TS       - S    539332 87284 php
82856 82856 TS       - Ssl  1728760 18204 nomad
82866 82866 TS       - S    539144 86672 php
82928 82928 TS       - Ssl  1532408 17992 nomad
82939 82939 TS       - S    539056 86876 php
83027 83027 TS       - Ssl  1524468 17520 nomad
83037 83037 TS       - S    539260 87016 php
83122 83122 TS       - Ssl  1663224 18024 nomad
83132 83132 TS       - S    539368 87136 php
83133 83133 TS       - Ssl  1663736 18792 nomad
83144 83144 TS       - S    539296 86964 php
83146 83146 TS       - Ssl  1729528 18408 nomad
83156 83156 TS       - S    537108 85280 php
83742 83742 TS       - Ssl  1532664 17628 nomad
83753 83753 TS       - S    539288 87332 php
85638 85638 TS       - S         0     0 kworker/8:2
86302 86302 TS       - Ssl  1466616 18236 nomad
86303 86303 TS       - Ssl  1523956 18620 nomad
86322 86322 TS       - S    521804 68748 php
86323 86323 TS       - S    521804 69012 php
86325 86325 TS       - Ssl  1794808 17688 nomad
86332 86332 TS       - Ssl  1532152 17936 nomad
86342 86342 TS       - S    521804 68744 php
86347 86347 TS       - S    521804 68748 php
86349 86349 TS       - Ssl  1597944 18140 nomad
86360 86360 TS       - S    521804 69012 php
86361 86361 TS       - Ssl  1597944 18628 nomad
86372 86372 TS       - S    521808 68748 php
86373 86373 TS       - Ssl  1598200 18700 nomad
86386 86386 TS       - S    521808 68744 php
86387 86387 TS       - Ssl  1532664 17776 nomad
86399 86399 TS       - S    521804 69012 php
86401 86401 TS       - Ssl  1597688 18352 nomad
86411 86411 TS       - S    521804 68744 php
87124 87124 TS       - Ssl  1597432 17920 nomad
87135 87135 TS       - S    523112 70484 php
87779 87779 TS       - S         0     0 kworker/9:2
88651 88651 TS       - Ssl  1597432 17824 nomad
88662 88662 TS       - S    523320 71008 php
89440 89440 TS       - S     89812  4060 pickup
90989 90989 TS       - S         0     0 kworker/11:2
91605 91605 TS       - Ssl  1532472 18860 nomad
91616 91616 TS       - S    524788 72560 php
91825 91825 TS       - S         0     0 kworker/1:2
92695 92695 TS       - Ssl  1523700 18040 nomad
92706 92706 TS       - S    523228 72428 php
94473 94473 TS       - Ssl  1663480 18056 nomad
94482 94482 TS       - S    519732 68672 php
94586 94586 TS       - Ssl  905640  9716 filebeat
94906 94906 TS       - S         0     0 kworker/7:1
95248 95248 TS       - S         0     0 kworker/0:1
95554 95554 TS       - Ssl  1598200 18116 nomad
95562 95562 TS       - Ssl  789232 48752 consul
95574 95574 TS       - S    536040 83960 php
95799 95799 TS       - Ssl  1655284 18664 nomad
95810 95810 TS       - S    559348 109760 php
97514 97514 TS       - S         0     0 kworker/3:2

anastazya avatar Jan 20 '21 16:01 anastazya

Ok, so the first thing I worried about was leaking Nomad processes. You've got 93 php processes (not counting the php-fpm) and 187 nomad processes. That's 2 nomad processes for each php process, plus 1 more for the Nomad agent. That's what I'd expect to see, as each task has a task executor and a logmon log collector. We'd generally expect that to add up to a couple of GB of RSS just because of the sheer number of processes.

If we do a bit of math we can see that ~7GB of RSS are dedicated to php but a whopping 14.6GB is dedicated to nomad! I plotted a quickie histogram and (if we discard the outlier which is the Nomad agent), we can see there's a group of ~20 processes that are eating up almost half of that total and are individually 100-300MB of RSS.

Screen Shot 2021-01-20 at 1 54 03 PM

A couple things that would be useful to help debug this:

  • Are those large processes executor or logmon processes?
  • What exact Nomad version are you using (nomad --version)?

It might also be useful to see if there's a relationship between the etimes and the RSS of the Nomad process. Something like ps -eo pid,comm,args,rss,etimes would give us a table of that relationship, including the args that let us differentiate between executor and logmon, or if you have graphs from whatever you're sending those collectd metrics to. That would let us see if one of the specific processes has a memory leak.

I've done some very quick tests here and I don't see any obvious leaks on the executor or logmon for a process that's doing frequent logging. But you may be encountering this issue more seriously because of the large number of tasks on the host. It looks like you're running a task-per-php, so if it's possible to spawn them behind a single php-fpm you might have efficiency gains that will help reduce the problem while we work on figuring this out.

(Also, I hope you don't mind but I edited your last response to wrap that ps dump in a <details> block for readability.)

tgross avatar Jan 20 '21 19:01 tgross

Nomad v1.0.0 (cfca6405ad9b5f66dffc8843e3d16f92f3bedb43)

The rest of the details i will compile today as this is somewhat production environment.

 PID COMMAND         COMMAND                       RSS ELAPSED
    1 systemd         /usr/lib/systemd/systemd --  4184  700688
    2 kthreadd        [kthreadd]                      0  700688
    4 kworker/0:0H    [kworker/0:0H]                  0  700688
    6 ksoftirqd/0     [ksoftirqd/0]                   0  700688
    7 migration/0     [migration/0]                   0  700688
    8 rcu_bh          [rcu_bh]                        0  700688
    9 rcu_sched       [rcu_sched]                     0  700688
   10 lru-add-drain   [lru-add-drain]                 0  700688
   11 watchdog/0      [watchdog/0]                    0  700688
   12 watchdog/1      [watchdog/1]                    0  700688
   13 migration/1     [migration/1]                   0  700688
   14 ksoftirqd/1     [ksoftirqd/1]                   0  700688
   16 kworker/1:0H    [kworker/1:0H]                  0  700688
   17 watchdog/2      [watchdog/2]                    0  700688
   18 migration/2     [migration/2]                   0  700688
   19 ksoftirqd/2     [ksoftirqd/2]                   0  700688
   21 kworker/2:0H    [kworker/2:0H]                  0  700688
   22 watchdog/3      [watchdog/3]                    0  700688
   23 migration/3     [migration/3]                   0  700688
   24 ksoftirqd/3     [ksoftirqd/3]                   0  700688
   26 kworker/3:0H    [kworker/3:0H]                  0  700688
   27 watchdog/4      [watchdog/4]                    0  700688
   28 migration/4     [migration/4]                   0  700688
   29 ksoftirqd/4     [ksoftirqd/4]                   0  700688
   31 kworker/4:0H    [kworker/4:0H]                  0  700688
   32 watchdog/5      [watchdog/5]                    0  700688
   33 migration/5     [migration/5]                   0  700688
   34 ksoftirqd/5     [ksoftirqd/5]                   0  700688
   36 kworker/5:0H    [kworker/5:0H]                  0  700688
   37 watchdog/6      [watchdog/6]                    0  700688
   38 migration/6     [migration/6]                   0  700688
   39 ksoftirqd/6     [ksoftirqd/6]                   0  700688
   41 kworker/6:0H    [kworker/6:0H]                  0  700688
   42 watchdog/7      [watchdog/7]                    0  700688
   43 migration/7     [migration/7]                   0  700688
   44 ksoftirqd/7     [ksoftirqd/7]                   0  700688
   46 kworker/7:0H    [kworker/7:0H]                  0  700688
   47 watchdog/8      [watchdog/8]                    0  700688
   48 migration/8     [migration/8]                   0  700688
   49 ksoftirqd/8     [ksoftirqd/8]                   0  700688
   51 kworker/8:0H    [kworker/8:0H]                  0  700688
   52 watchdog/9      [watchdog/9]                    0  700688
   53 migration/9     [migration/9]                   0  700688
   54 ksoftirqd/9     [ksoftirqd/9]                   0  700688
   56 kworker/9:0H    [kworker/9:0H]                  0  700688
   57 watchdog/10     [watchdog/10]                   0  700688
   58 migration/10    [migration/10]                  0  700688
   59 ksoftirqd/10    [ksoftirqd/10]                  0  700688
   61 kworker/10:0H   [kworker/10:0H]                 0  700688
   62 watchdog/11     [watchdog/11]                   0  700688
   63 migration/11    [migration/11]                  0  700688
   64 ksoftirqd/11    [ksoftirqd/11]                  0  700688
   66 kworker/11:0H   [kworker/11:0H]                 0  700688
   68 kdevtmpfs       [kdevtmpfs]                     0  700688
   69 netns           [netns]                         0  700688
   70 khungtaskd      [khungtaskd]                    0  700688
   71 writeback       [writeback]                     0  700688
   72 kintegrityd     [kintegrityd]                   0  700688
   73 bioset          [bioset]                        0  700688
   74 bioset          [bioset]                        0  700688
   75 bioset          [bioset]                        0  700688
   76 kblockd         [kblockd]                       0  700688
   77 md              [md]                            0  700688
   78 edac-poller     [edac-poller]                   0  700688
   79 watchdogd       [watchdogd]                     0  700688
   85 kswapd0         [kswapd0]                       0  700688
   86 ksmd            [ksmd]                          0  700688
   87 khugepaged      [khugepaged]                    0  700688
   88 crypto          [crypto]                        0  700688
   96 kthrotld        [kthrotld]                      0  700688
   98 kmpath_rdacd    [kmpath_rdacd]                  0  700688
   99 kaluad          [kaluad]                        0  700688
  101 kpsmoused       [kpsmoused]                     0  700688
  102 ipv6_addrconf   [ipv6_addrconf]                 0  700688
  115 deferwq         [deferwq]                       0  700688
  153 kauditd         [kauditd]                       0  700688
  358 ata_sff         [ata_sff]                       0  700688
  362 scsi_eh_0       [scsi_eh_0]                     0  700688
  363 scsi_tmf_0      [scsi_tmf_0]                    0  700688
  364 scsi_eh_1       [scsi_eh_1]                     0  700688
  365 scsi_tmf_1      [scsi_tmf_1]                    0  700688
  370 ttm_swap        [ttm_swap]                      0  700687
  377 virtscsi-scan   [virtscsi-scan]                 0  700687
  378 scsi_eh_2       [scsi_eh_2]                     0  700687
  379 scsi_tmf_2      [scsi_tmf_2]                    0  700687
  414 kworker/0:1H    [kworker/0:1H]                  0  700687
  459 kdmflush        [kdmflush]                      0  700687
  460 bioset          [bioset]                        0  700687
  471 kdmflush        [kdmflush]                      0  700687
  472 bioset          [bioset]                        0  700687
  485 bioset          [bioset]                        0  700687
  486 xfsalloc        [xfsalloc]                      0  700687
  487 xfs_mru_cache   [xfs_mru_cache]                 0  700687
  488 xfs-buf/dm-0    [xfs-buf/dm-0]                  0  700687
  489 xfs-data/dm-0   [xfs-data/dm-0]                 0  700687
  490 xfs-conv/dm-0   [xfs-conv/dm-0]                 0  700687
  491 xfs-cil/dm-0    [xfs-cil/dm-0]                  0  700687
  492 xfs-reclaim/dm- [xfs-reclaim/dm-]               0  700687
  493 xfs-log/dm-0    [xfs-log/dm-0]                  0  700687
  494 xfs-eofblocks/d [xfs-eofblocks/d]               0  700687
  495 xfsaild/dm-0    [xfsaild/dm-0]                  0  700687
  577 systemd-journal /usr/lib/systemd/systemd-jo 38160  700687
  597 lvmetad         /usr/sbin/lvmetad -f         2544  700686
  613 systemd-udevd   /usr/lib/systemd/systemd-ud  1352  700686
  660 hwrng           [hwrng]                         0  700686
  695 kworker/5:1H    [kworker/5:1H]                  0  700686
  747 jbd2/sda1-8     [jbd2/sda1-8]                   0  700685
  748 ext4-rsv-conver [ext4-rsv-conver]               0  700685
  781 auditd          /sbin/auditd                  716  700685
  785 rpciod          [rpciod]                        0  700685
  786 xprtiod         [xprtiod]                       0  700685
  809 rpcbind         /sbin/rpcbind -w              636  700685
  810 statsd-aggregat /usr/bin/statsd-aggregator    436  700685
  813 dbus-daemon     /usr/bin/dbus-daemon --syst  1404  700685
  841 qemu-ga         /usr/bin/qemu-ga --method=v  1496  700685
  863 irqbalance      /usr/sbin/irqbalance --fore   696  700685
  878 ntpd            /usr/sbin/ntpd -u ntp:ntp -  1436  700685
  924 crond           /usr/sbin/crond -n           1120  700685
  995 kworker/8:1H    [kworker/8:1H]                  0  700685
  997 kworker/10:1H   [kworker/10:1H]                 0  700682
  998 kworker/2:1H    [kworker/2:1H]                  0  700682
 1060 node_exporter   /opt/node_exporter/node_exp 25040  700681
 1063 lldpd           /usr/sbin/lldpd              1668  700681
 1064 puppet          /usr/bin/ruby /usr/bin/pupp 37104  700681
 1073 lldpd           /usr/sbin/lldpd              1276  700681
 1079 sshd            /usr/sbin/sshd -D            1572  700681
 1081 tuned           /usr/bin/python2 -Es /usr/s 11940  700681
 1082 php-fpm         php-fpm: master process (/e 10224  700681
 1086 java            /bin/java -Djava.io.tmpdir= 307984 700681
 1102 consul          /usr/bin/consul agent -conf 50516  700681
 1169 rsyslogd        /usr/sbin/rsyslogd -n       24200  700681
 1197 consul-template /usr/bin/consul-template -c 235744 700681
 1207 containerd      /usr/bin/containerd         20388  700681
 1241 osqueryd        /usr/bin/osqueryd --flagfil  1228  700681
 1295 haproxy         /usr/sbin/haproxy -sf 3464  12328  700680
 1312 unbound         /usr/sbin/unbound -d        11540  700680
 1344 osqueryd        /usr/bin/osqueryd           24808  700680
 1418 agetty          /sbin/agetty --noclear tty1   408  700680
 1445 php-fpm         php-fpm: pool www             872  700680
 1447 php-fpm         php-fpm: pool www             896  700680
 1450 php-fpm         php-fpm: pool www             860  700680
 1451 php-fpm         php-fpm: pool www             892  700680
 1452 php-fpm         php-fpm: pool www            2948  700680
 1572 dockerd         /usr/bin/dockerd -H fd:// - 50260  700680
 1640 master          /usr/libexec/postfix/master  1428  700680
 1643 qmgr            qmgr -l -t unix -u           1468  700680
 1801 sensu-client    /opt/sensu/embedded/bin/rub 19284  700680
 2189 kworker/7:1H    [kworker/7:1H]                  0  700676
 2488 nomad           /usr/bin/nomad executor {"L 19744    1099
 2498 php             /usr/bin/php /var/www/worke 71344    1099
 2946 systemd-logind  /usr/lib/systemd/systemd-lo  1728  700666
 3006 nomad           /usr/bin/nomad executor {"L 18824    1089
 3017 php             /usr/bin/php /var/www/worke 87188    1089
 3110 nomad           /usr/bin/nomad executor {"L 10648  700666
 3116 nomad           /usr/bin/nomad executor {"L 16576  700666
 3157 nomad           /usr/bin/nomad executor {"L  5052  700666
 3160 collectd        /usr/sbin/collectd           1548  700666
 3173 nomad           /usr/bin/nomad executor {"L 14712  700666
 3192 nomad           /usr/bin/nomad logmon       13476  700666
 3237 nomad           /usr/bin/nomad executor {"L 12740  700666
 3238 nomad           /usr/bin/nomad logmon       17256  700666
 3241 nomad           /usr/bin/nomad executor {"L 14868  700666
 3258 nomad           /usr/bin/nomad executor {"L  5144  700666
 3288 nomad           /usr/bin/nomad executor {"L  4968  700666
 3304 nomad           /usr/bin/nomad executor {"L  5180  700666
 3308 nomad           /usr/bin/nomad executor {"L  5136  700666
 3842 nomad           /usr/bin/nomad logmon       15536  700658
 3844 nomad           /usr/bin/nomad logmon       17096  700658
 3864 nomad           /usr/bin/nomad logmon        5168  700658
 3870 nomad           /usr/bin/nomad logmon        5152  700658
 3892 nomad           /usr/bin/nomad logmon        5096  700658
 3893 nomad           /usr/bin/nomad logmon        5140  700658
 3894 nomad           /usr/bin/nomad logmon        5132  700658
 3905 nomad           /usr/bin/nomad logmon        4876  700658
 4073 nomad           /usr/bin/nomad agent -confi 1541964 700656
 4179 kworker/6:1H    [kworker/6:1H]                  0  700653
 4718 nomad           /usr/bin/nomad executor {"L 13560  700650
 4934 nomad           /usr/bin/nomad executor {"L 13616  700650
 5862 kworker/4:1H    [kworker/4:1H]                  0  700647
 6023 nomad           /usr/bin/nomad logmon       318864 700644
 6024 nomad           /usr/bin/nomad logmon       57544  700644
 6052 nomad           /usr/bin/nomad logmon       314160 700644
 6064 nomad           /usr/bin/nomad logmon       59340  700644
 6074 nomad           /usr/bin/nomad logmon       316272 700644
 6084 nomad           /usr/bin/nomad logmon       319728 700644
 6109 nomad           /usr/bin/nomad logmon       312672 700644
 6129 nomad           /usr/bin/nomad logmon       56112  700644
 6151 nomad           /usr/bin/nomad logmon       161628 700644
 6169 nomad           /usr/bin/nomad logmon       61172  700644
 6194 nomad           /usr/bin/nomad logmon       58776  700644
 6212 nomad           /usr/bin/nomad logmon       314736 700644
 6226 nomad           /usr/bin/nomad logmon       349440 700644
 6242 nomad           /usr/bin/nomad logmon       315620 700644
 6279 nomad           /usr/bin/nomad logmon       71804  700644
 6300 nomad           /usr/bin/nomad logmon       52312  700644
 6317 nomad           /usr/bin/nomad logmon       72740  700644
 6348 nomad           /usr/bin/nomad logmon       62420  700644
 6363 nomad           /usr/bin/nomad logmon       316572 700644
 6374 nomad           /usr/bin/nomad logmon       310544 700644
 6410 nomad           /usr/bin/nomad logmon       61344  700644
 6436 nomad           /usr/bin/nomad logmon       67696  700644
 6454 nomad           /usr/bin/nomad logmon       48784  700644
 6470 nomad           /usr/bin/nomad logmon       56688  700644
 6503 nomad           /usr/bin/nomad logmon       60448  700644
 6521 nomad           /usr/bin/nomad logmon       320804 700644
 6531 nomad           /usr/bin/nomad logmon       341828 700644
 6557 nomad           /usr/bin/nomad logmon       322156 700644
 6560 nomad           /usr/bin/nomad logmon       154872 700644
 6625 nomad           /usr/bin/nomad logmon       61668  700644
 6634 nomad           /usr/bin/nomad logmon       56748  700644
 6660 nomad           /usr/bin/nomad logmon       64356  700644
 6688 nomad           /usr/bin/nomad logmon       62024  700644
 6691 nomad           /usr/bin/nomad logmon       318896 700643
 6713 nomad           /usr/bin/nomad logmon       318220 700643
 6731 nomad           /usr/bin/nomad logmon       322184 700643
 6745 nomad           /usr/bin/nomad logmon       316588 700643
 6788 nomad           /usr/bin/nomad logmon       54464  700643
 6799 nomad           /usr/bin/nomad logmon       323116 700643
 6813 nomad           /usr/bin/nomad logmon       321448 700643
 6871 nomad           /usr/bin/nomad logmon       321516 700643
 6879 nomad           /usr/bin/nomad logmon       321296 700643
 6895 nomad           /usr/bin/nomad logmon       1399932 700643
 6925 nomad           /usr/bin/nomad logmon       56132  700643
 6931 nomad           /usr/bin/nomad logmon       75528  700643
 6955 nomad           /usr/bin/nomad logmon       58340  700643
 7045 nomad           /usr/bin/nomad logmon       250960 700643
 7051 nomad           /usr/bin/nomad logmon       47116  700643
 7073 nomad           /usr/bin/nomad logmon       1381968 700643
 7074 nomad           /usr/bin/nomad logmon       60984  700643
 7095 nomad           /usr/bin/nomad logmon       57224  700643
 7437 kworker/1:1H    [kworker/1:1H]                  0  700641
 7546 kworker/4:0     [kworker/4:0]                   0   10171
 9119 nomad           /usr/bin/nomad executor {"L 19492    1002
 9131 php             /usr/bin/php /var/www/worke 86944    1002
 9412 nomad           /usr/bin/nomad executor {"L 18588     995
 9422 php             /usr/bin/php /var/www/worke 88152     995
11994 kworker/3:1H    [kworker/3:1H]                  0  700565
12987 kworker/7:2     [kworker/7:2]                   0    2741
13098 nomad           /usr/bin/nomad executor {"L 18188     931
13109 php             /usr/bin/php /var/www/worke 69948     931
13111 nomad           /usr/bin/nomad executor {"L 18956     929
13122 php             /usr/bin/php /var/www/worke 69948     929
14200 nomad           /usr/bin/nomad executor {"L 18988     908
14211 php             /usr/bin/php /var/www/worke 75164     908
14256 nomad           /usr/bin/nomad executor {"L 18760     907
14267 php             /usr/bin/php /var/www/worke 73424     907
14380 nomad           /usr/bin/nomad executor {"L 18832     906
14391 php             /usr/bin/php /var/www/worke 73352     906
14392 nomad           /usr/bin/nomad executor {"L 18612     906
14403 php             /usr/bin/php /var/www/worke 74908     906
14494 nomad           /usr/bin/nomad executor {"L 18672     903
14505 php             /usr/bin/php /var/www/worke 74520     903
14516 nomad           /usr/bin/nomad executor {"L 18124     902
14527 php             /usr/bin/php /var/www/worke 74412     902
14543 nomad           /usr/bin/nomad executor {"L 17880     902
14553 php             /usr/bin/php /var/www/worke 74856     902
14580 nomad           /usr/bin/nomad executor {"L 19328     902
14590 php             /usr/bin/php /var/www/worke 146460    902
14760 kworker/3:1     [kworker/3:1]                   0   59815
15117 nomad           /usr/bin/nomad executor {"L 18272     894
15128 php             /usr/bin/php /var/www/worke 73684     894
15130 nomad           /usr/bin/nomad executor {"L 19116     893
15141 php             /usr/bin/php /var/www/worke 74636     893
15696 nomad           /usr/bin/nomad executor {"L 19588     882
15706 php             /usr/bin/php -dmemory_limit 153804    882
15708 nomad           /usr/bin/nomad executor {"L 18612     882
15718 php             /usr/bin/php -dmemory_limit 141988    882
15851 kworker/11:1H   [kworker/11:1H]                 0  700494
19663 kworker/8:0     [kworker/8:0]                   0    2614
20768 nomad           /usr/bin/nomad executor {"L 18108     789
20779 php             /usr/bin/php /var/www/worke 68896     788
23702 nomad           /usr/bin/nomad executor {"L 18592     729
23713 php             /usr/bin/php /var/www/worke 71808     729
24006 kworker/1:2     [kworker/1:2]                   0     723
24562 nomad           /usr/bin/nomad executor {"L 18972     716
24572 php             /usr/bin/php /var/www/worke 70192     716
25410 nomad           /usr/bin/nomad executor {"L 17784     698
25420 php             /usr/bin/php /var/www/worke 94872     698
27468 kworker/11:1    [kworker/11:1]                  0    7953
27872 kworker/9:1H    [kworker/9:1H]                  0  700273
29344 nomad           /usr/bin/nomad executor {"L 18336     629
29356 php             /usr/bin/php /var/www/worke 82528     629
31148 nomad           /usr/bin/nomad executor {"L 18676     597
31157 php             /usr/bin/php -dmemory_limit 75648     597
32569 filebeat        /usr/share/filebeat/bin/fil 22760  700193
32674 python          /usr/bin/python /usr/share/ 12876  700192
33015 kworker/u192:1  [kworker/u192:1]                0     564
33272 mcollectived    /usr/bin/ruby /usr/sbin/mco 44880  700184
34642 nomad           /usr/bin/nomad executor {"L 18224     538
34652 php             /usr/bin/php /var/www/worke 71508     538
35622 nomad           /usr/bin/nomad executor {"L 18216     522
35633 php             /usr/bin/php -dmemory_limit 107460    522
35986 kworker/5:2     [kworker/5:2]                   0     514
35999 kworker/2:2     [kworker/2:2]                   0     513
37008 nomad           /usr/bin/nomad executor {"L 18772     494
37018 php             /usr/bin/php /var/www/worke 114116    494
39347 kworker/7:0     [kworker/7:0]                   0     453
42596 kworker/11:0    [kworker/11:0]                  0     394
42707 kworker/1:1     [kworker/1:1]                   0     392
44527 kworker/9:1     [kworker/9:1]                   0    2133
46559 nomad           /usr/bin/nomad executor {"L 19412    2095
46581 php             /usr/bin/php /var/www/worke 111400   2095
46920 nomad           /usr/bin/nomad executor {"L 18276     313
46931 php             /usr/bin/php /var/www/worke 130436    313
47307 kworker/10:0    [kworker/10:0]                  0    2081
48697 haproxy         /usr/sbin/haproxy -sf 3464  17848   42357
48996 nomad           /usr/bin/nomad executor {"L 19584    2048
49006 php             /usr/bin/php /var/www/worke 99548    2048
49343 nomad           /usr/bin/nomad executor {"L 18296     269
49353 php             /usr/bin/php /var/www/worke 68636     269
49442 kworker/8:1     [kworker/8:1]                   0     266
49503 nomad           /usr/bin/nomad executor {"L 19036     266
49518 php             /usr/bin/php /var/www/worke 68636     266
49573 nomad           /usr/bin/nomad executor {"L 17940     265
49584 php             /usr/bin/php /var/www/worke 68636     265
49845 nomad           /usr/bin/nomad executor {"L 18140     260
49856 php             /usr/bin/php /var/www/worke 68616     260
52954 nomad           /usr/bin/nomad executor {"L 18788     201
52965 php             /usr/bin/php -dmemory_limit 122648    201
53723 nomad           /usr/bin/nomad executor {"L 18036     187
53734 php             /usr/bin/php /var/www/worke 86884     187
53735 nomad           /usr/bin/nomad executor {"L 17836     187
53743 nomad           /usr/bin/nomad executor {"L 18544     187
53752 php             /usr/bin/php /var/www/worke 87068     187
53757 php             /usr/bin/php /var/www/worke 86832     187
53759 nomad           /usr/bin/nomad executor {"L 17808     186
53769 php             /usr/bin/php /var/www/worke 87200     186
53940 nomad           /usr/bin/nomad executor {"L 17948     184
53951 php             /usr/bin/php /var/www/worke 87256     184
53958 nomad           /usr/bin/nomad executor {"L 18132     183
53968 php             /usr/bin/php /var/www/worke 86516     183
54871 nomad           /usr/bin/nomad executor {"L 18360     165
54882 php             /usr/bin/php /var/www/worke 87096     165
55156 nomad           /usr/bin/nomad executor {"L 17656     159
55166 php             /usr/bin/php /var/www/worke 110572    159
55418 nomad           /usr/bin/nomad executor {"L 18672     156
55428 php             /usr/bin/php /var/www/worke 110208    156
55430 nomad           /usr/bin/nomad executor {"L 18924     156
55440 php             /usr/bin/php /var/www/worke 107664    156
55582 kworker/10:1    [kworker/10:1]                  0     153
56031 nomad           /usr/bin/nomad executor {"L 17920     144
56042 php             /usr/bin/php /var/www/worke 88728     144
56382 kworker/3:0     [kworker/3:0]                   0    7413
57053 nomad           /usr/bin/nomad executor {"L 18364     123
57064 php             /usr/bin/php /var/www/worke 68628     123
57134 kworker/6:1     [kworker/6:1]                   0    1894
57154 kworker/0:1     [kworker/0:1]                   0   29732
57232 nomad           /usr/bin/nomad executor {"L 18888     122
57242 php             /usr/bin/php /var/www/worke 68632     122
57331 nomad           /usr/bin/nomad executor {"L 18160     120
57341 php             /usr/bin/php /var/www/worke 68632     120
57823 nomad           /usr/bin/nomad executor {"L 18276     112
57833 php             /usr/bin/php /var/www/worke 68628     112
57918 nomad           /usr/bin/nomad executor {"L 18364     109
57928 php             /usr/bin/php /var/www/worke 68716     109
58104 nomad           /usr/bin/nomad executor {"L 17604     107
58114 php             /usr/bin/php /var/www/worke 68632     107
58117 nomad           /usr/bin/nomad executor {"L 17604     106
58127 php             /usr/bin/php /var/www/worke 68628     106
58492 nomad           /usr/bin/nomad executor {"L 18096      99
58503 php             /usr/bin/php /var/www/worke 68632      99
58678 nomad           /usr/bin/nomad executor {"L 19344      96
58688 php             /usr/bin/php /var/www/worke 68628      96
58799 nomad           /usr/bin/nomad executor {"L 18508      93
58809 php             /usr/bin/php /var/www/worke 72292      93
59295 kworker/3:2     [kworker/3:2]                   0      86
59642 nomad           /usr/bin/nomad executor {"L 18432      77
59653 php             /usr/bin/php /var/www/worke 68632      77
59902 nomad           /usr/bin/nomad executor {"L 17552      75
59913 php             /usr/bin/php /var/www/worke 68632      75
59918 nomad           /usr/bin/nomad executor {"L 18048      74
59928 php             /usr/bin/php /var/www/worke 68632      74
60027 nomad           /usr/bin/nomad executor {"L 17900      71
60038 php             /usr/bin/php /var/www/worke 68632      71
60300 nomad           /usr/bin/nomad executor {"L 18684      66
60311 php             /usr/bin/php /var/www/worke 73156      66
60485 nomad           /usr/bin/nomad executor {"L 17772      63
60496 php             /usr/bin/php -dmemory_limit 68620      63
62019 kworker/6:2     [kworker/6:2]                   0   24095
62082 crond           /usr/sbin/CROND -n           2564      33
62083 sh              /bin/sh -c /opt/pupstream/p  1196      33
62085 puppet_cron.sh  /bin/sh /opt/pupstream/pupp  1420      33
62092 sleep           sleep 127                     356      33
62337 nomad           /usr/bin/nomad executor {"L 16392      28
62351 php             /usr/bin/php /var/www/worke 72300      28
62889 sshd            sshd: ansible-deploy [priv]  5696      17
62891 sshd            sshd: ansible-deploy@pts/0   2616      16
62892 bash            -bash                        3024      16
63033 nomad           /usr/bin/nomad executor {"L 16768      15
63045 php             /usr/bin/php -dmemory_limit 69160      15
63097 sudo            sudo su                      4716      14
63098 su              su                           2360      14
63099 bash            bash                         2964      14
63630 nomad           /usr/bin/nomad executor {"L 15592       4
63640 php             /usr/bin/php /var/www/worke 68628       4
63730 ps              ps -eo pid,comm,args,rss,et  1504       0
63801 nomad           /usr/bin/nomad executor {"L 18592    1767
63811 php             /usr/bin/php /var/www/worke 70188    1767
67436 nomad           /usr/bin/nomad logmon       251576 617599
67452 nomad           /usr/bin/nomad logmon       47124  617599
67453 nomad           /usr/bin/nomad logmon       48092  617599
67479 nomad           /usr/bin/nomad logmon       66592  617599
67485 nomad           /usr/bin/nomad logmon       58244  617599
67489 nomad           /usr/bin/nomad logmon       61000  617599
67514 nomad           /usr/bin/nomad logmon       275304 617599
67535 nomad           /usr/bin/nomad logmon       54628  617599
67563 nomad           /usr/bin/nomad logmon       51568  617598
67599 nomad           /usr/bin/nomad logmon       52988  617598
67620 nomad           /usr/bin/nomad logmon       48380  617598
67628 nomad           /usr/bin/nomad logmon       44244  617598
67649 nomad           /usr/bin/nomad logmon       69452  617598
67659 nomad           /usr/bin/nomad logmon       62412  617598
67703 nomad           /usr/bin/nomad logmon       50692  617598
67706 kworker/0:14    [kworker/0:14]                  0   36635
67720 nomad           /usr/bin/nomad logmon       68512  617598
67721 nomad           /usr/bin/nomad logmon       71844  617598
67742 nomad           /usr/bin/nomad logmon       74704  617598
67888 nomad           /usr/bin/nomad logmon       45880  617598
67903 nomad           /usr/bin/nomad logmon       52728  617598
67914 nomad           /usr/bin/nomad logmon       59180  617598
67936 nomad           /usr/bin/nomad logmon       48196  617598
67941 nomad           /usr/bin/nomad logmon       51140  617598
67987 nomad           /usr/bin/nomad logmon       45484  617598
67992 nomad           /usr/bin/nomad logmon       57856  617598
68007 nomad           /usr/bin/nomad logmon       46296  617598
68383 nomad           /usr/bin/nomad executor {"L 18524    1678
68394 php             /usr/bin/php /var/www/worke 95760    1678
70201 nomad           /usr/bin/nomad executor {"L 19688    1644
70211 php             /usr/bin/php /var/www/worke 71232    1644
71939 kworker/10:8    [kworker/10:8]                  0   51263
72485 pickup          pickup -l -t unix -u         3816    3454
72619 kworker/u192:2  [kworker/u192:2]                0    1603
73652 kworker/4:1     [kworker/4:1]                   0    1590
74925 kworker/9:2     [kworker/9:2]                   0   14493
79622 nomad           /usr/bin/nomad executor {"L 19084    1481
79636 php             /usr/bin/php /var/www/worke 108536   1481
79950 kworker/5:0     [kworker/5:0]                   0   54877
80027 nomad           /usr/bin/nomad executor {"L 18884    1475
80037 php             /usr/bin/php /var/www/worke 94060    1475
80136 kworker/8:2     [kworker/8:2]                   0    1474
84300 nomad           /usr/bin/nomad executor {"L 19108    1399
84311 php             /usr/bin/php /var/www/worke 76528    1399
84312 nomad           /usr/bin/nomad executor {"L 19280    1399
84324 php             /usr/bin/php /var/www/worke 68896    1399
86573 nomad           /usr/bin/nomad executor {"L 18872    1357
86583 php             /usr/bin/php /var/www/worke 115768   1357
86681 kworker/1:0     [kworker/1:0]                   0    1355
88503 kworker/0:0     [kworker/0:0]                   0   36255
91194 nomad           /usr/bin/nomad executor {"L 18940    1271
91205 php             /usr/bin/php /var/www/worke 90428    1271
91404 nomad           /usr/bin/nomad executor {"L 18188    1268
91414 php             /usr/bin/php /var/www/worke 110592   1267
94313 nomad           /usr/bin/nomad executor {"L 19696    1213
94323 php             /usr/bin/php /var/www/worke 103596   1213
94872 kworker/2:1     [kworker/2:1]                   0   32608
97865 nomad           /usr/bin/nomad executor {"L 18344    1143
97875 php             /usr/bin/php /var/www/worke 134060   1143

anastazya avatar Jan 21 '21 07:01 anastazya

@anastazya I did some quick rummaging thru those numbers and it looks like there's no relationship between etime and memory (if anything, the executors seem to free up memory a tiny bit the older they are). But the logmon processes are grabbing a lot more RSS than I might expect, and there are two outlier logmon processes that are each eating up 1+GB of memory each. The primary way I'd expect to see this is if the logmon processes have queued up a lot of messages that aren't yet committed to disk, although I'm surprised that wouldn't result in dropped messages first... I need to dig into that code. In any it might be worth looking at the host's disk IO utilization.

With that clue, I'll see if I can set up a reproduction that'll cause logmon's memory to expand unexpectedly.

tgross avatar Jan 21 '21 22:01 tgross

The primary way I'd expect to see this is if the logmon processes have queued up a lot of messages that aren't yet committed to disk, although I'm surprised that wouldn't result in dropped messages first... I need to dig into that code.

Well that was totally off-base... we have a fifo with blocking reads with a small buffer, so that's just not something that would happen without also blocking the log writer of your application.

I've been trying to get a reproduction here by having an raw_exec task that sends "excessive" logs (~100MB/s worth). At that volume, I get the RSS of the logmon to slowly climb up to ~35MB and then it levels out. I've tried varying the line-length of the log to see if there was a bug in the way we try to span newlines for file rotation and that hasn't panned out. I've tried varying the log file size via logs.max_file_size to see more rapid log rotation can detect a leak we'd otherwise miss, but so far I've found nothing there either. I thought I had a promising lead for file handles leaking, but that turned out to be references to the same file handle for log rotation.

The total RSS does seem proportion to log volume though: if I tune the throughput of the logs by sending small web request logs instead of literally running cat shakespere_macbeth.txt in a loop, the RSS is considerably smaller. Given that the RSS of go applications is effectively a "high water mark" because the runtime almost never gives memory back to the OS, that suggests the logmon is just creating the various buffers it needs to do Write and rotation, but that there's something unusual about this log workload that I haven't quite figured out yet.

With more information about your log load, I might be able to narrow things down. Do you have a logs configuration? Are the logs unusually high volume? Do they have long lines (maybe they're wide structured events)?

tgross avatar Jan 22 '21 20:01 tgross

The primary way I'd expect to see this is if the logmon processes have queued up a lot of messages that aren't yet committed to disk, although I'm surprised that wouldn't result in dropped messages first... I need to dig into that code.

Well that was totally off-base... we have a fifo with blocking reads with a small buffer, so that's just not something that would happen without also blocking the log writer of your application.

I've been trying to get a reproduction here by having an raw_exec task that sends "excessive" logs (~100MB/s worth). At that volume, I get the RSS of the logmon to slowly climb up to ~35MB and then it levels out. I've tried varying the line-length of the log to see if there was a bug in the way we try to span newlines for file rotation and that hasn't panned out. I've tried varying the log file size via logs.max_file_size to see more rapid log rotation can detect a leak we'd otherwise miss, but so far I've found nothing there either. I thought I had a promising lead for file handles leaking, but that turned out to be references to the same file handle for log rotation.

The total RSS does seem proportion to log volume though: if I tune the throughput of the logs by sending small web request logs instead of literally running cat shakespere_macbeth.txt in a loop, the RSS is considerably smaller. Given that the RSS of go applications is effectively a "high water mark" because the runtime almost never gives memory back to the OS, that suggests the logmon is just creating the various buffers it needs to do Write and rotation, but that there's something unusual about this log workload that I haven't quite figured out yet.

With more information about your log load, I might be able to narrow things down. Do you have a logs ? Are the logs unusually high volume? Do they have long lines (maybe they're wide structured events)?

The logs config across all jobs is like this :

  logs {
    max_files = 1
    max_file_size = 1
  } 

I will get back with the log volume, needs investigation.

anastazya avatar Jan 27 '21 11:01 anastazya

That's very interesting... I'd expect that to result in very rapid log rotation if the volume of logs is reasonably high, which might be triggering buffering while the rotation is happening. That gives me something else to look at, at least, but the log volume would be interesting to see for sure.

May I ask why such a low value for these?

tgross avatar Jan 27 '21 14:01 tgross

That's very interesting... I'd expect that to result in very rapid log rotation if the volume of logs is reasonably high, which might be triggering buffering while the rotation is happening. That gives me something else to look at, at least, but the log volume would be interesting to see for sure.

May I ask why such a low value for these?

We thought in the beginning to log only bear minimum and minimise the storage impact and IOPS usage. But if you say this has a great impact on log rotating, we will change those values. Any recommendation ?

anastazya avatar Jan 28 '21 09:01 anastazya

But if you say this has a great impact on log rotating, we will change those values. Any recommendation ?

That entirely depends on the log volume. If you're only sending a trickle of logs it doesn't matter. But you're sending >1MB of logs a second then you're rotating the logs continuously. You almost certainly want the logs to be rotating less often than it the time it takes to actually rotate them. We don't compress the logs, so it should be quick unless the disk is getting hammered (which of course it might be if you're writing that many logs!). It's definitely worth comparing the log volume to the overall IOPS usage.

tgross avatar Jan 28 '21 13:01 tgross

But if you say this has a great impact on log rotating, we will change those values. Any recommendation ?

That entirely depends on the log volume. If you're only sending a trickle of logs it doesn't matter. But you're sending >1MB of logs a second then you're rotating the logs continuously. You almost certainly want the logs to be rotating less often than it the time it takes to actually rotate them. We don't compress the logs, so it should be quick unless the disk is getting hammered (which of course it might be if you're writing that many logs!). It's definitely worth comparing the log volume to the overall IOPS usage.

I will be doing in depth tests next week and write here if i find something LOG related. As far as i see the logging is not that aggressive.

anastazya avatar Jan 29 '21 09:01 anastazya

I've encountered a scenario where Nomad consumed a lot of memory (over 5GB), I eventually found out it happened because of tasks that keep restarting forever due to insufficient resources or bad arguments. Maybe this will help you.

Edit: Just to elaborate, the task restarting issue helped to decrease the memory usage to 1GB in some cases, in others it released some memory but was still high. I can't say for sure that the trigger to that issue is the fault task but I didn't encounter the high memory usage where all of my tasks were valid.

HaCStudio avatar Feb 01 '21 08:02 HaCStudio

I've encountered a scenario where Nomad consumed a lot of memory (over 5GB), I eventually found out it happened because of tasks that keep restarting forever due to insufficient resources or bad arguments. Maybe this will help you.

Edit: Just to elaborate, the task restarting issue helped to decrease the memory usage to 1GB in some cases, in others it released some memory but was still high. I can't say for sure that the trigger to that issue is the fault task but I didn't encounter the high memory usage where all of my tasks were valid.

I can assure you that all the tasks run well and don't restart with errors.

anastazya avatar Feb 01 '21 13:02 anastazya

I looked at it a bit more, the issue I described is referring only to when Nomad agent uses high memory. I also have the same issue with "nomad logmon" without any errors on the Nomad monitor logs. I'm using Windows server, if you need any additional details that will help you investigate let me know. Nomad version is 0.12.7

HaCStudio avatar Feb 01 '21 14:02 HaCStudio

@Nickleby9 let's open that as a new issue then, so as not to confuse this issue.

tgross avatar Feb 01 '21 14:02 tgross

Screenshot 2021-02-04 at 19 59 14

After adding this modification :

logs {​​​​​​​​ max_files = 10 max_file_size = 10 }​​​​​​​​

Today i found half the Nomad nodes like the picture. Besides restarting the nomad agent, there was nothing i could do. After nomad agent restart, it started working normal again.

anastazya avatar Feb 12 '21 08:02 anastazya

I still need to come back to review this, but just saw that go1.16 dropped with the following improvement (ref https://golang.org/doc/go1.16#runtime):

On Linux, the runtime now defaults to releasing memory to the operating system promptly (using MADV_DONTNEED), rather than lazily when the operating system is under memory pressure (using MADV_FREE). This means process-level memory statistics like RSS will more accurately reflect the amount of physical memory being used by Go processes. Systems that are currently using GODEBUG=madvdontneed=1 to improve memory monitoring behavior no longer need to set this environment variable.

I suspect this is going to help us out in Nomad quite a bit because logmon is in the allocation resource boundary. I'm not sure if we'll ship that in the upcoming Nomad 1.0.4, but certainly for Nomad 1.1.

tgross avatar Feb 16 '21 21:02 tgross

@tgross sorry, any updates? I can see this problem still not solved in 1.1 version of Nomad?

bubejur avatar May 20 '21 11:05 bubejur

@tgross sorry, any updates? I can see this problem still not solved in 1.1 version of Nomad?

Hi @bubejur we just shipped Nomad 1.1 a couple days ago, so I'm sure @anastazya hasn't had a chance to try it out in their environment to verify whether MADV_DONTNEED helped us out here. If you were able to reliably reproduce the problem yourself on an earlier version of Nomad and can test it out, we'd love to hear about it.

tgross avatar May 20 '21 12:05 tgross

Okay. As i can see it: In previous versions (I tried all from 1.0.0 - till 1.0.6) there were problems with: [ERROR] client.driver_mgr.raw_exec: error receiving stream from Stats executor RPC, closing stream: alloc_id=2eba8886-94a2-0afc-8e2b-24e6af270728 driver=raw_exec task_name=Group-1-worker-0 error="rpc error: code = Unavailable desc = transport is closing" and some time ago (about 8h) logmon process takes >5% memory usage. And after 1 day I really need to restart nomad process to free up node memory. I hoped a lot about fix it at 1.1.0, but still have this issue...

bubejur avatar May 20 '21 12:05 bubejur