服务器崩溃 - 内存问题?紧急php-fpm重启不起作用

时间:2014-05-22 23:12:17

标签: memory amazon-ec2 crash php

经过数月的考验和磨难,我成功地让我的网站在亚马逊实例上运行相对有效。然而,不幸的是,有时服务器崩溃,似乎是随机的时间。这些崩溃是在Web服务器启动几天后发生的,通常发生在非高峰时段。

Web服务器当前位于包含7.5 GB Ram的c3.xlarge实例上,我将pm.max_children设置为60,将php的memory_limit设置为128M。通过Linux运行top命令时,apache进程的平均RES值在80M范围内。我认为这个问题围绕着内存使用问题,但我并不积极。记忆似乎逐渐增加。当服务器崩溃时,我可以通过运行php-fpm restart轻松恢复生命,但这显然不是一个长期的解决方案。

查看错误日志时,我发现:

[16-May-2014 12:35:26] NOTICE: child 10404 stopped for tracing
[16-May-2014 12:35:26] NOTICE: about to trace 10404
[16-May-2014 12:35:26] ERROR: failed to ptrace(PEEKDATA) pid 10404: Input/output error (5)
[16-May-2014 12:35:26] NOTICE: finished trace of 10404
[16-May-2014 12:35:26] NOTICE: child 10405 stopped for tracing
[16-May-2014 12:35:26] NOTICE: about to trace 10405
[16-May-2014 12:35:26] ERROR: failed to ptrace(PEEKDATA) pid 10405: Input/output error (5)
[16-May-2014 12:35:26] NOTICE: finished trace of 10405

以及......

 [16-May-2014 12:35:33] WARNING: [pool www] child 9424 exited on signal 15 (SIGTERM) after 126.568819 seconds from start
 [16-May-2014 12:35:33] NOTICE: [pool www] child 10537 started
 [16-May-2014 12:35:33] WARNING: [pool www] child 10122 exited on signal 15 (SIGTERM) after 59.041135 seconds from start
 [16-May-2014 12:35:33] NOTICE: [pool www] child 10538 started
 [16-May-2014 12:35:33] WARNING: [pool www] child 8881 exited on signal 15 (SIGTERM) after 175.978531 seconds from start
 [16-May-2014 12:35:33] NOTICE: [pool www] child 10539 started
 [16-May-2014 12:35:33] WARNING: [pool www] child 7099 exited on signal 15 (SIGTERM) after 310.218902 seconds from start
 [16-May-2014 12:35:33] NOTICE: [pool www] child 10540 started
 [16-May-2014 12:35:33] WARNING: [pool www] child 6282 exited on signal 15 (SIGTERM) after 380.138489 seconds from start

虽然我理想情况下会找到问题的根源并纠正问题,但紧急变量听起来像是一个有效的解决方案,但它们似乎并没有自动重置php-fpm。

emergency_restart_threshold = 3
emergency_restart_interval = 1m
process_control_timeout = 10s

关于内存问题的任何想法?或者当孩子以信号15退出时,为什么这些紧急变量不会自动重启php-fpm?是否可以在每日计时器上重启php-fpm?

0 个答案:

没有答案