Here's my config (Nginx 1.7.x) :
server {
listen 8000;
index index.php index.html index.htm;
root /var/www/;
server_tokens off;
chunked_transfer_encoding off;
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_keep_conn on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
And php-fpm config:
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 6000;
pm.process_idle_timeout = 5;
chdir = /
security.limit_extensions = .php
php_flag[display_errors] = on
php_flag[display_startup_errors] = on
I have a PHP script from which i send LIVE DATA to the client.. When the client closes the connection, I can see that the PID is being closed after 15-20 seconds. I think this is due to buffer and the way nginx works .
For example if I disable the nginx/fastcgi buffering by setting fastcgi_buffering off the connection of the client is being closed instantly.
However, the nginx buffering is very important for me to reduce any lag from the client if found.
So is there any way that nginx/php can instantly get the event when a client disconnects even when I have the buffering on?
Thank you
0 Answers