优化Nginx + PHP-FPM以缩短响应时间(用于Openx广告服务)
我目前正在运行Nginx + PHP-FPM,以便在OpenX上投放广告。目前,即使在低负载时期,我的响应时间也很可怕。但是,我的CPU和内存资源很好,所以我似乎无法弄清楚瓶颈是什么。
我目前对nginx和php-fpm的配置是:
worker_processes 20;
worker_rlimit_nofile 50000;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 15000;
multi_accept off;
use epoll;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
tcp_nopush off;
keepalive_timeout 0;
#keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
# Default location
location / {
root /var/www;
index index.php;
}
## Parse all .php file in the /var/www directory
location ~ .php$ {
fastcgi_pass localhost:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$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_ignore_client_abort off;
}
PHP-FPM:
rlimit_files = 50000
max_children = 500
我只包含我为PHP-FPM更改的PHP-FPM参数。
有没有人对我如何优化它以便我可以处理更多请求有任何提示?我现在看到可怕的响应时间。