PHP数据文件,可以作为一个数据存储方案。但是,这种方案仅仅适合数据量小的情况,数据量大的情况下容易出现性能的下降。这次,发现了一个隐藏的比较深的BUG。一般来说,PHP文件数据量太大,会造成超出内存限制而发生错误,服务器会返回500错误。但是,这次服务器返回的是502错误,PHP错误并无日志。初步定位后,发现这个问题跟PHP数据文件有关,只要include该数据文件,即报502错误。
502错误(Bad Gateway)网关错误,可以猜出php-cgi进程已经挂掉了,检查php-fpm日志
1)检查php-fpm日志
Nov 18 11:49:12.553181 [NOTICE] fpm_got_signal(), line 48: received SIGCHLD
Nov 18 11:49:12.554976 [WARNING] fpm_children_bury(), line 215: child 13585 (pool default) exited on signal 11 SIGSEGV (core dumped) after 588684.743947 seconds from start
Nov 18 11:49:12.559363 [NOTICE] fpm_children_make(), line 352: child 9021 (pool default) started
果然,php-cgi进程发生了异常,宕掉了。
Nov 18 12:02:55 localhost abrtd: Directory 'ccpp-2015-11-18-12:02:54-13391' creation detected
Nov 18 12:02:55 localhost abrt[26465]: Saved core dump of pid 13391 (/usr/local/webserver/php/bin/php-cgi) to /var/spool/abrt/ccpp-2015-11-18-12:02:54-13391 (137519104 bytes)
Nov 18 12:02:55 localhost abrtd: Package 'custom-php' isn't signed with proper key
Nov 18 12:02:55 localhost abrtd: 'post-create' on '/var/spool/abrt/ccpp-2015-11-18-12:02:54-13391' exited with 1
Nov 18 12:02:55 localhost abrtd: Corrupted or bad directory /var/spool/abrt/ccpp-2015-11-18-12:02:54-13391, deleting
#0 0x00007f370e35f443 in optimize_bb (bb=0x7fffc4e16ce0, op_array=0x19988f8,
global=0x7fffc4e14c80 "", pass=0) at /home/tmp/ex/eaccelerator/optimize.c:1664
初步定位是由于 eaccelerator引发的问题
Segmentation fault
总结:
1)尽可能避免使用PHP文件来存储大数据
2)适当升级PHP版本,新版本原则上更多bug被发现,性能也更好