From a5424368eaa1e59082cdec5f97ec50c061c6a9d8 Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Wed, 9 Oct 2024 17:39:41 +0200 Subject: [PATCH] fix(php-fpm): Set a good process children default for bigger servers --- docs/roles/debian/php-fpm.md | 5 ++++- roles/debian/php-fpm/defaults/main.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/roles/debian/php-fpm.md b/docs/roles/debian/php-fpm.md index 94a687ac4..1c6484680 100644 --- a/docs/roles/debian/php-fpm.md +++ b/docs/roles/debian/php-fpm.md @@ -20,7 +20,10 @@ php: pool_group: "{{ user_deploy.username }}" # if using unix socket this should be the web server user pm: dynamic # can also be static, see https://tideways.com/profiler/blog/an-introduction-to-php-fpm-tuning default_socket_timeout: 60 - max_children: 5 + # It is important to scale up processes on bigger servers, so that more + # requests can be handled. Double the number of vCPUs is a good default. + # Can be between 5 and 64. + max_children: "{{ [5, [ansible_facts.processor_vcpus * 2, 64] | min] | max }}" start_servers: 2 min_spare_servers: 1 max_spare_servers: 3 diff --git a/roles/debian/php-fpm/defaults/main.yml b/roles/debian/php-fpm/defaults/main.yml index b6fea0c7d..bd11bd594 100644 --- a/roles/debian/php-fpm/defaults/main.yml +++ b/roles/debian/php-fpm/defaults/main.yml @@ -10,7 +10,10 @@ php: pool_group: "{{ user_deploy.username }}" # if using unix socket this should be the web server user pm: dynamic # can also be static, see https://tideways.com/profiler/blog/an-introduction-to-php-fpm-tuning default_socket_timeout: 60 - max_children: 5 + # It is important to scale up processes on bigger servers, so that more + # requests can be handled. Double the number of vCPUs is a good default. + # Can be between 5 and 64. + max_children: "{{ [5, [ansible_facts.processor_vcpus * 2, 64] | min] | max }}" start_servers: 2 min_spare_servers: 1 max_spare_servers: 3