nginx php-fpm segfault那点事

来源:互联网 发布:怀孕31周b超数据 编辑:程序博客网 时间:2024/05/19 13:28

lnmp一键服务器装机,完成,app搞定,开始试着发展几个用户吧。

总是隔三差五的超时。

查看message日志,总是能看到几行红色的

kernel: [5612713.463986] php-fpm[12410]: segfault at 6f3cc0 ip 00000000006fee94 sp 00007fff41c76d80 error 7 in php-fpm[400000+75e000]

很咋眼。

这可以理解了,当用户很荣幸的分到这个fpm进程的时候,不是bad gateway就是timeout。

首先怀疑库不兼容,不过没道理啊,全是编译安装的,应该都一致,卸载一些不必要的程序,依旧不行。

然后停掉不必要的服务,值保留nginx,phpfpm,停掉memcache,redis。依旧不行。

写了个内存监控脚本,发现出现问题的时候,内存变化不明显。

写了个负载监控的脚本,发现负载变化不明显。

于是开始优化参数,从nginx,到php,到fpm,终于发现一个可疑的参数。

backlog,学过linux内核的人都知道,他是tcp连接建立过程中的一个控制参数,

The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.

实际上在linux内核2.2版本以后,backlog参数控制的是已经握手成功的还在accept queue的大小。

那么是不是phpfpm的backlog是干什么用的呢?是不是也是与连接有关呢?

有位大神帮忙实验了

http://blog.sina.com.cn/s/blog_714afb2b0101ftca.html

但是他的问题我也解决不了,我只知道我的机器-1,性能很差,我改成1024,再也没有出现segfault的问题。


0 0
原创粉丝点击