Reputation: 383
I am using php-fpm with nginx. I have scripts which take an uploaded excel sheet and process it. This is a long running job. However, after 60 seconds of execution time I get a 504 Gateway Timeout error.
The php script keeps running to completion. So nothing is stopping the script from completing.
I need to stop this error.
I have been playing with the fastcgi_read_timeout parameter. However it doesn't seem to fix this problem. However I know it's taking this parameter into consideration because if I change it to 0 and restart nginx, then the 504 gateway timeout shows straight away.
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm/www.sock;
fastcgi_read_timeout 300;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "upload_max_filesize = 190M \n post_max_size=190M \n max_execution_time = 300";
}
Any help would be appreciated as I have hit a roadblock in terms of resolving this issue.
Upvotes: 4
Views: 4908
Reputation: 383
I almost completely gave up on this! However at the last minute I came up with the answer.
The servers are on Amazon AWS behind a load balancer. The load balancer had the idle-timeout attribute set at 60 seconds. Changing this setting fixed the problem!!
Upvotes: 9