Alan Storm asked:
Me: New to nginx and FastCGI in general, apologies if this is old hat and obvious, but Googling shows me a lot of people recommending random configuration values, but no one that explains the reasoning behind their decisions.
What’s the relationship between an nginx worker_process and a PHP-FPM worker? Do more nginx workers means more PHP-FPM workers, or are they unrelated?
My understanding of how this works on a high level is
- User requests a web page
- nginx handles the request, sees it’s a PHP page
- nginx hands request off to PHP-FPM
- PHP-FPM either handles the request with an existing process, or spawns new ones
What’s unclear to me if there’s any relationship between PHP-FPM spawning a new child processes, and which nginx worker processes are talking to it. i.e. if you had two identical web server, one with
worker_process = 4 and another with
worker_process = 8, and they both saw identical web traffic, would one server create more php-fpm child processes than another? Or have I said something so stupid here that it shows I’m missing a fundamental concept? (if so, what?)
Not trying to solve a specific problem — just trying to learn how to reason about the behavior of nginx and php-fpm so I can contribute to scaling and performance brainstorms/troubleshooting.
There is no inherent relation between nginx
worker_processes and php-fpm children. They don’t even have to be running on the same machine! But if they are on the same machine, they can contend for CPU (which usually isn’t a problem as nginx requires very little CPU compared to PHP).
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.