I would like to clarify how php-fpm manages workers with dynamic process manager.
Let's assume we have following config:
pm = dynamic
pm.max_children = 100
pm.start_servers = 30
pm.min_spare_servers = 20
pm.max_spare_servers = 60
- when php-fpm starts, it spawns 30 processes
- there are no connections. Will the php-fpm shut down 10 workers according to min_spare_servers setting? If yes, after what time will it happen?
- There are 40 connections to nginx. Will php-fpm serve each connection with separate worker, and immediately spawn additional workers to satisfy remaining connections?
- There are 80 connections to nginx. How will php-fpm behave after it has launched 60 workers? The same as in (3)?
- There are 120 connections to nginx. What happens after assigning 100 workers to 100 connections? Does php-fpm use some queue for the connections? Will it limit nginx? Will php-fpm start dropping connections with message "server reached pm.max_children setting"?
- There are 50 connections to nginx. Will nginx go back to 60 connections from 100? Or to 50? Will it immediately kill 40 workers or will it wait some time?
As you see, this is rather a generalized question about how php-fpm manages processes. More specifically, I would like to understand the difference between pm.max_children and pm.max_spare_servers in php-fpm.