yanqzh 发表于 2017-3-12 09:37:34

频繁502错误,恳请军哥指教

系统centos7 ,lnmp1.3,php7.0 ,mysql5.7.,内存4G,双核心。安装了memcached,启用了opcache
# netstat -anpo | grep "php-cgi" | wc -l
1

# free -m
             total       used       free   shared    buffers   cached
Mem:          3832       3112      719          0      451      483
-/+ buffers/cache:       2177       1654
Swap:            0          0          0

#top
top - 09:10:35 up 23:57,1 user,load average: 0.32, 0.30, 0.27
Tasks: 167 total,   1 running, 166 sleeping,   0 stopped,   0 zombie
Cpu(s):0.3%us,0.2%sy,0.0%ni, 99.0%id,0.5%wa,0.0%hi,0.0%si,0.0%st
Mem:   3924164k total,3229268k used,   694896k free,   462044k buffers
Swap:      0k total,      0k used,      0k free,   497168k cached

PID USER      PRNIVIRTRESSHR S %CPU %MEM    TIME+COMMAND                                                                                                                        
4805 www       20   0419m44m35m S1.31.2   0:03.47 php-fpm                                                                                                                           
4818 www       20   0419m49m37m S0.31.3   0:04.80 php-fpm                                                                                                                           
5909 root      20   0 15032 1268928 R0.30.0   0:00.05 top                                                                                                                              
30754 mysql   20   0 2295m 1.7g 7836 S0.3 45.6   7:01.13 mysqld                                                                                                                           
    1 root      20   0 19356 1364 1048 S0.00.0   0:01.16 init      


探针显示的系统负载均衡



nginx.conf部分配置:
worker_processes auto;
error_log/home/wwwlogs/nginx_error.logcrit;
pid      /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
worker_connections 51200;

      fastcgi_connect_timeout 300;
      fastcgi_send_timeout 300;
      fastcgi_read_timeout 300;
      fastcgi_buffer_size 64k;
      fastcgi_buffers 4 64k;
      fastcgi_busy_buffers_size 128k;
      fastcgi_temp_file_write_size 256k;
      gzip on;
      gzip_min_length1k;
      gzip_buffers   4 16k;
      gzip_http_version 1.1;
      gzip_comp_level 2;


php-fpm.conf部分配置:
listen = /tmp/php-cgi.sock
listen.allowed_clients = 127.0.0.1
pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 200
request_terminate_timeout = 100
request_slowlog_timeout = 0


opcache配置:

opcache.enable=1
zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/opcache.so
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.file_cache=/tmp


探针里php相关参数



/usr/local/php/var/log/php-fpm.log部分错误:
NOTICE: fpm is running, pid 24916
NOTICE: ready to handle connections
WARNING: child 24920 exited on signal 11 (SIGSEGV - core dumped) after 30567.129989 seconds from start
NOTICE: child 2347 started
WARNING: child 24918 exited on signal 11 (SIGSEGV - core dumped) after 31322.164367 seconds from start
NOTICE: child 2608 started
WARNING: child 24922 exited on signal 11 (SIGSEGV - core dumped) after 38178.746541 seconds from start
NOTICE: child 4785 started
WARNING: child 24926 exited on signal 11 (SIGSEGV - core dumped) after 38180.449634 seconds from start
NOTICE: child 4787 started
WARNING: child 24925 exited on signal 11 (SIGSEGV - core dumped) after 38182.988441 seconds from start
NOTICE: child 4789 started
NOTICE: Finishing ...
NOTICE: exiting, bye-bye!
NOTICE: fpm is running, pid 4802
NOTICE: ready to handle connections


nginx_errors.log部分数据:
2017/03/11 17:37:40 21838#0: *1 connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory) while connecting to upstream, client: 106.38.241.141, server: aaaaaaa.com, request: "GET /index.php?title=Index.html&category-view-2-82_html=&mobileaction=toggle_view_desktop HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "aaaaaaaaaa.com"
2017/03/11 17:55:28 29396#0: *1 connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory) while connecting to upstream, client: 106.38.241.141, server: aaaaaaaa.com, request: "GET /title/%E5%A4%8F%E6%9E%AF%E8%8D%89 HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "aaaaaaaaa.com"

licess 发表于 2017-3-12 13:40:18

你这日子都不发同一时间段的,按nginx错误日子上是php-fpm挂了,按php-fpm日子是有程序执行超时,可以自己开慢日志看看具体的php程序

yanqzh 发表于 2017-3-13 09:26:19

回复 2# 的帖子

一、如何提高探针里的cache化内存呢?
对于cache化内存是否可以这样理解:
cache化的内存越大,服务器的cache功能就越好,网站响应及加载速度就越高?

那么问题来了,cache化内存如何提高?以前php5.X时,只要安装xcache,探针里cache化内存的展示图形长度,就必定比真实内存的展示图形长度要长,但是php7下,xcache无法 安装。

二、php-fpm.conf内关于child的设置貌似无效,配置是:
pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 20
pm.max_spare_servers = 200
request_terminate_timeout = 600
request_slowlog_timeout = 600
slowlog = var/log/slow.log
但/usr/local/php/var/log/php-fpm.log提示:
WARNING: seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 16 idle, and 30 total children
这是怎么回事呢?
# netstat -anpo | grep "php-cgi" | wc -l
显示数目是1

licess 发表于 2017-3-13 11:12:06

内存为系统自动管理,你就是用了xcache,没那么大的访问量,该占多少还是占多少

你把terminate 调小些

只有php 5.2上是php-cgi,5.3及之后早就都是php-fpm了
页: [1]
查看完整版本: 频繁502错误,恳请军哥指教