Last active
April 4, 2023 02:23
-
-
Save jhowbhz/908e46a0a055d7be9b25b201c81d6f84 to your computer and use it in GitHub Desktop.
PHP-FPM settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP-FPM settings tutorial. max_servers, min_servers, etc. | |
echo Cores = $(( $(lscpu | awk '/^Socket/{ print $2 }') * $(lscpu | awk '/^Core/{ print $4 }') )) | |
When you run the Linux command above, you will get something like “Cores = 4”. | |
ps --no-headers -o "rss,cmd" -C php-fpm7.2 | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }' | |
When I ran the command above, I got 29M. | |
/etc/php/7.2/fpm/pool.d/www.conf | |
pm.max_children | |
pm.start_servers | |
pm.min_spare_servers | |
pm.max_spare_servers | |
pm.max_children | |
In my case, I want to allocate 4GB (4000MB) and each process consumes about 29MB. | |
Divide 4000 by 29 and you get around 138. | |
pm.max_children to 138. | |
pm.start_servers = 16 | |
pm.min_spare_servers = 32 | |
pm.max_spare_servers = 8 | |
So I set pm.max_spare_servers to 16, the same value that I used for pm.start_servers. | |
Restart PHP FPM. | |
For these changes to take effect, you will need to restart PHP FPM. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment