独角兽因内存不足而被杀死

时间:2017-10-11 14:13:58

标签: ruby-on-rails postgresql unicorn

今天,我注意到独角兽没有在生产环境中运行。 Unicorn错误日志如下(由于SIGKILL信号似乎停止了独角兽):

D, [2017-10-11T12:25:49.521336 #9375] DEBUG -- : waiting 16.0s after suspend/hibernation
E, [2017-10-11T12:26:08.051349 #9375] ERROR -- : reaped #<Process::Status: pid 9535 SIGKILL (signal 9)> worker=1
I, [2017-10-11T12:26:21.708135 #9375]  INFO -- : worker=1 spawning...
当独角兽被杀时,我们遇到了一个记忆力不足的问题。在/var/log/syslog.1中,我有以下日志:

Oct 11 12:26:02 analiz kernel: [4486147.309450]  [<ffffffff81190979>] out_of_memory+0x219/0x460
Oct 11 12:26:02 analiz kernel: [4486147.309677] Out of memory: Kill process 9375 (ruby2.3) score 81 or sacrifice child

现在我的问题是;

  1. 我怎样才能确保unicorn即使被内核杀死也会自动重启? (例如,30秒后自动重启)
  2. 在正常操作中,内存利用率约为%50-%60。我想了解根本原因,并采取措施防止将来出现类似问题。根据系统日志消息,内存不足问题是从postgres开始的。我不知道是什么导致了postgres或其他进程的高内存利用率。任何形式的支持将不胜感激。
  3. Oct 11 12:26:02 analiz kernel: [4486147.309419] postgres invoked oom-killer: gfp_mask=0x24200ca, order=0, oom_score_adj=0
    Oct 11 12:26:02 analiz kernel: [4486147.309422] postgres cpuset=/ mems_allowed=0
    Oct 11 12:26:02 analiz kernel: [4486147.309427] CPU: 0 PID: 9570 Comm: postgres Not tainted 4.4.0-1031-aws #40-Ubuntu
    Oct 11 12:26:02 analiz kernel: [4486147.309428] Hardware name: Xen HVM domU, BIOS 4.2.amazon 02/16/2017
    Oct 11 12:26:02 analiz kernel: [4486147.309429]  0000000000000286 08956ec91b465ba3 ffff88000918f9e8 ffffffff813f6ec3
    Oct 11 12:26:02 analiz kernel: [4486147.309432]  ffff88000918fba0 ffff88003cfdb700 ffff88000918fa58 ffffffff81208b3a
    Oct 11 12:26:02 analiz kernel: [4486147.309433]  ffffffff81cc3661 0000000000000000 ffffffff81e667a0 0000000000000206
    

    提前致谢。

0 个答案:

没有答案