I have a one line PHP script that prints out the PID using getmypid()
, every time the script is called via FPM the PID changes, but I expected the pid to be the same. I thought the whole point of FPM was that a new process would not be spawned every time, thereby making things faster?

- 3,693
- 7
- 23
- 37

- 1,141
- 1
- 10
- 27
-
is it a *completely new one* every time? or is it one out of a *set* of PIDs? a set, perhaps, containing *n* different PIDs, where *n* is the amount of CPU threads your machine has? – Franz Gleichmann Dec 06 '16 at 12:47
1 Answers
This, you would probably need to understand php fpm configuration a little bit in your www.conf file (or whatever conf file depending on your OS). So depending on your configuration, FPM will usually fork more children depending on your demands hence different pid number.
Choose how the process manager will control the number of child processes.
Possible Values:
static - a fixed number (pm.max_children) of child processesdynamic - the number of child processes are set dynamically based on the following directives. With this process management, there will be always at least 1 children.
pm.max_children - the maximum number of children that can be alive at the same time.
pm.start_servers - the number of children created on startup.pm.min_spare_servers - the minimum number of children in 'idle' state (waiting to process). If the number of 'idle' processes is less than this number then some children will be created.
pm.max_spare_servers - the maximum number of children in 'idle' state (waiting to process). If the number of 'idle' processes is greater than this number then some children will be killed.ondemand - no children are created at startup. Children will be forked when new requests will connect.
The following parameter are used:
pm.max_children - the maximum number of children that can be alive at the same time.
pm.process_idle_timeout - The number of seconds after which an idle process will be killed. Note: This value is mandatory.

- 1
- 1

- 12,479
- 7
- 45
- 76