on demand: spanning of every request cpu & slower wait for specified seconds 10s and dies. good for small and saves memory
static: directly allocating or dedicating max memory memory limit 128M* connection or children 100 pools *128M =12800MB or 12.8GB
Dynamic: better for medium traffic website slightly performance and memory saving but little headache.
some approaches set php fpm dynamic pool
Setting | Value |
---|---|
max_children | (Total RAM – Memory used for Linux, DB, etc.) / process size |
start_servers | Number of CPU cores x 4 |
min_spare_servers | Number of CPU cores x 2 |
max_spare_servers | Same as start_servers |
8gb ram 2gb for system 6gb for php -fpm
pm.process_idle_timeout not using in dynamic used in ondemand default 10s;
porcess size in liunx Determining Average memory usage per process
ps –no-headers -o ‘rss,cmd’ -C php-fpm8.1 | awk ‘{ sum+=$1 } END { printf (‘%d%s\n’, sum/NR/1024,’M’) }’
average size 64MB but php ma_memory limit 256MB so it go may beyothe limit then we need to monitor.
64*100=6400 6.4gb
Setting | Value |
---|---|
max_children | 100 |
start_servers | 32 |
min_spare_servers | 16 |
max_spare_servers | 32 |
increase pm.start_servers, or pm.min/max_spare_servers not pm.max_children
i set pm.max_children = 120 but dynamic pool only used upto 24 children nad restarted,
also asking to increase start and spare server not max children
dynamic pool manager not using max children limit
pm.max_children = 120
pm.start_servers = 4
pm.min_spare_servers = 2
pm.max_spare_servers = 5
max used children 24 ,
the formula
pm.start_servers = 4
Default Value: (min_spare_servers + max_spare_servers) / 2
pm.max_spare_servers = 5 increaseed from 5
config test
php-fpm8.1 -t
[06-Aug-2023 06:19:21] NOTICE: configuration file /etc/php/8.1/fpm/php-fpm.conf test is successful
pm.max_children = 120 to 2
config test
php-fpm8.1 -t
[06-Aug-2023 06:35:26] ALERT: [pool sarkari] pm.min_spare_servers(2) and pm.max_spare_servers(20) cannot be greater than pm.max_children(2)
[06-Aug-2023 06:35:26] ERROR: failed to post process the configuration
[06-Aug-2023 06:35:26] ERROR: FPM initialization failed
2nd case scenario
pm.max_children = 100
pm.start_servers = 15
pm.min_spare_servers = 15
pm.max_spare_servers = 25
32gb of RAM and 8 cores
[20-May-2019 14:23:02] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 4 idle, and 22 total children
[20-May-2019 14:23:03] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 3 idle, and 30 total children
[20-May-2019 14:23:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 42 total children
[20-May-2019 14:23:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 57 total children
[20-May-2019 14:23:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 72 total children
[20-May-2019 14:23:07] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 87 total children
[20-May-2019 14:23:08] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 102 total children
[20-May-2019 14:23:09] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 117 total children
[20-May-2019 14:23:10] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 9 idle, and 132 total children
log file implies 110 processes started in 8 seconds. Note that it started multiple batches of 32 in quick succession. pm.min_spare_servers = 15 will not be able to absorb such a connection increase, response time will be terrible.
Faqs
children vs servers in php fpm
those are same
Is pm.max_children used in php fpm dyamic pool?
yes as per the config test above
[30-Jul-2023 01:19:19] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[30-Jul-2023 01:19:20] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[30-Jul-2023 01:19:21] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 14 total children
[31-Jul-2023 03:26:09] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[31-Jul-2023 03:26:10] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[31-Jul-2023 03:26:11] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 14 total children
[31-Jul-2023 03:26:12] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 16 total children
[31-Jul-2023 03:26:13] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 18 total children
[31-Jul-2023 03:26:15] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 20 total children
[31-Jul-2023 03:26:16] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 22 total children
[31-Jul-2023 08:58:40] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 1 idle, and 11 total children
[31-Jul-2023 08:58:41] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 1 idle, and 12 total children
[31-Jul-2023 08:58:42] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 13 total children
[31-Jul-2023 08:58:43] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 14 total children
[31-Jul-2023 08:58:45] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 15 total children
[31-Jul-2023 16:42:28] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[31-Jul-2023 16:42:29] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[31-Jul-2023 16:42:36] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 18 total children
[31-Jul-2023 16:42:37] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 20 total children
[31-Jul-2023 16:42:38] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 22 total children
[31-Jul-2023 16:42:39] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 24 total children
[01-Aug-2023 04:45:26] WARNING: [pool www] server reached max_children setting (10), consider raising it
[01-Aug-2023 05:00:58] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 1 idle, and 10 total children
[01-Aug-2023 05:01:11] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 1 idle, and 14 total children
[01-Aug-2023 05:01:12] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 15 total children
[01-Aug-2023 05:01:13] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 17 total children
[01-Aug-2023 05:01:16] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 19 total children
[01-Aug-2023 05:01:53] NOTICE: Terminating …
[01-Aug-2023 05:01:53] NOTICE: exiting, bye-bye!
[01-Aug-2023 05:02:19] NOTICE: fpm is running, pid 4135329
[01-Aug-2023 05:02:19] NOTICE: ready to handle connections
[01-Aug-2023 05:02:19] NOTICE: systemd monitor interval set to 10000ms
[03-Aug-2023 05:47:50] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[03-Aug-2023 05:48:22] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 16 total children
[03-Aug-2023 05:48:24] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 1 idle, and 18 total children
[03-Aug-2023 05:48:27] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 19 total children
[03-Aug-2023 05:48:30] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 20 total children
[03-Aug-2023 05:48:40] NOTICE: Terminating …
[03-Aug-2023 05:48:40] NOTICE: exiting, bye-bye!
[03-Aug-2023 06:24:24] NOTICE: fpm is running, pid 101392
[03-Aug-2023 06:24:24] NOTICE: ready to handle connections
[03-Aug-2023 06:24:24] NOTICE: systemd monitor interval set to 10000ms
[03-Aug-2023 18:15:06] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[03-Aug-2023 18:15:07] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[03-Aug-2023 18:15:08] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 14 total children
[03-Aug-2023 18:15:10] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 16 total children
[04-Aug-2023 04:04:28] WARNING: [pool www] server reached max_children setting (10), consider raising it
[04-Aug-2023 08:56:56] WARNING: [pool www] server reached max_children setting (10), consider raising it
[04-Aug-2023 08:56:58] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[04-Aug-2023 08:56:59] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[04-Aug-2023 08:57:00] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 14 total children
[04-Aug-2023 08:57:01] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 16 total children
[04-Aug-2023 08:57:02] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 18 total children
[04-Aug-2023 08:57:03] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 20 total children
[04-Aug-2023 08:57:05] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 22 total children
[04-Aug-2023 08:57:06] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 24 total children
[05-Aug-2023 08:41:40] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 1 idle, and 14 total children
[05-Aug-2023 08:41:41] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 1 idle, and 15 total children
[05-Aug-2023 08:41:42] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 16 total children
[05-Aug-2023 08:41:44] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 17 total children
[05-Aug-2023 08:41:46] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 18 total children
[05-Aug-2023 08:41:47] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 1 idle, and 19 total children
[05-Aug-2023 22:18:09] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 10 total children
[05-Aug-2023 22:18:10] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 12 total children
[05-Aug-2023 22:18:11] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 14 total children
[05-Aug-2023 22:18:12] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 16 total children
[05-Aug-2023 22:18:13] WARNING: [pool sarkari] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 18 total children
[05-Aug-2023 23:10:15] NOTICE: Terminating …
[05-Aug-2023 23:10:16] NOTICE: exiting, bye-bye!
dead oom killer. php fpm out of memory