Nginx and PHP-FPM running out of connections
Solution 1:
Have you considered following the fine advice provided in the log message, raising the value of pm.max_children
? You've got bucketloads of free RAM to accomodate them.
To answer your questions:
- What can I do to stop running out of connections? Provision more connections, or reduce the number of connections you receive.
- Why does this keep occurring? Because you keep running out of connections.
Solution 2:
We had the same issue on our webservers.
You can try to respawn the child process every X requests, to avoid memory leaks. It worked fine in Apache and FPM it's starting to work good as well.
pm.max_requests = 50000
This will restart a child process every 50k requests