nginx报502
nginx经常报这样的错误
2016/10/28 16:46:44 [error] 1919#0: *4340 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: www.xxxxx.com, request: "GET /test1.php HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "www.xxxxx.com"
与此同时,php-fpm 也会报这样的错
Oct 28 16:46:44.654727 [WARNING] [pool www] child 2175 exited on signal 7 SIGBUS after 0.025646 seconds from start
Oct 28 16:46:44.655233 [NOTICE] [pool www] child 2178 started
百度之后,看到一边文章
原因是在php包含了一个文件之后,这个文件又发生了修改,于是发生了错误
重现错误可以使用如下代码,使用ab
测试,就会报这样的错误
<?php
file_put_contents(__DIR__ . '/test.tpl', 'AAA<?php $string = "'. str_repeat('A', mt_rand(1, 256 * 1024)) .'"; ?>BBB' . "\r\n", LOCK_EX);
require_once __DIR__ . '/test.tpl';
echo "111";
?>
处理方法:
1、减少修改被包含的文件,模版解析之后的模版缓存文件