我们有一个运行Nginx PHP5-fpm apc设置的web服务器.
然而,我们最近在页面呈现过程中遇到上游连接超时错误和减速.快速的PHP5-fpm重新启动解决了问题,但是找不到原因.
我们有另一个Web服务器在另一个子域下运行apache2,连接同一个数据库,执行完全相同的作业.但是,这种减速只发生在Nginx-fpm服务器上.
我认为PHP5-fpm或apc可能会导致问题.
日志告诉各种连接超时:
上游超时(110:连接超时),同时连接到上游bla bla bla
PHP5-fpm日志没有显示任何内容.只是孩子开始和完成:
Apr 07 22:37:27.562177 [NOTICE] [pool www] child 29122 started
Apr 07 22:41:47.962883 [NOTICE] [pool www] child 28346 exited with code 0 after 2132.076556 seconds from start
Apr 07 22:41:47.963408 [NOTICE] [pool www] child 29172 started
Apr 07 22:43:57.235164 [NOTICE] [pool www] child 28372 exited with code 0 after 2129.135717 seconds from start
服务器没有加载,当发生错误和加载平均只有2(2cpus 16cores),PHP5-fpm进程似乎工作正常.
Nginx conf:
user www-data;
worker_processes 14;
pid /var/run/Nginx.pid;
# set open fd limit to 30000
worker_rlimit_nofile 30000;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/Nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/Nginx/access.log;
error_log /var/log/Nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+RSS text/javascript;
##
# Virtual Host Configs
##
include /etc/Nginx/conf.d/*.conf;
include /etc/Nginx/sites-enabled/*;
}
Nginx启用站点conf:
location ~* \.PHP${
fastcgi_split_path_info ^(.+\.PHP)(.*)$;
fastcgi_pass backend;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors off;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 20;
fastcgi_send_timeout 20;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
}
upstream backend {
server 127.0.0.1:9000;
}
fpm conf:
pm.max_children = 500
pm.start_servers = 100
pm.min_spare_servers = 50
pm.max_spare_servers = 100
pm.max_requests = 10000
fpm conf文件中有紧急重启设置.
我不知道他们是否帮助我们解决问题?
emergency_restart_interval = 0