Send 502 when all php-fpm workers are in use
Maxim Dounin
mdounin at mdounin.ru
Sun Jul 6 11:20:07 UTC 2014
Hello!
On Sat, Jul 05, 2014 at 10:47:43PM -0400, justink101 wrote:
> I have a php-fpm pool of workers which is 6. There are long running requests
> being sent, so I have the following fastcgi directives set:
>
> fastcgi_connect_timeout 15;
> fastcgi_send_timeout 1200;
> fastcgi_read_timeout 1200;
>
> However right now, if the php-fpm pool of workers is full, a request waits
> the full 20 minutes. I'd like requests to fail with a 502 status code if the
> php-fpm pool of workers is full instead. This change should still allow long
> running requests (max 20 minutes) though. I would have thought if the
> php-fpm pool workers are all being used, a request would timeout in 15
> seconds according to fastcgi_connect_timeout, but this does not seem to be
> the case.
>From nginx side a connection in a backend listen queue isn't
distinguishable from an accepted connection, hence
fastcgi_connect_timeout doesn't apply as long as a backend is
reacheable and it's listen queue isn't full. (And
fastcgi_send_timeout doesn't apply either if a request is small
enough to fit into socket send buffer.)
To reduce a number of affected requests you may consider using
smaller backlog in php-fpm, see here:
http://www.php.net/manual/en/install.fpm.configuration.php#listen-backlog
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list