From 33e7ad04003ec0d05469ca6b591d329f043dc21d Mon Sep 17 00:00:00 2001 From: Ravi Gummadi Date: Thu, 23 Feb 2017 05:34:06 -0500 Subject: [PATCH] Cap the number of worker threads Users can configure the number of worker threads however when it's not specified the calculated number of workers can get too large on hosts with a large number of CPUs. Change-Id: Idda6e476e9e9b5842c4cc03e9853ec31d123abc5 --- defaults/main.yml | 6 +++--- .../notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml | 5 +++++ templates/nginx.conf.j2 | 5 +---- 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 7b5bd17..44febeb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -# If ``repo_nginx_threads`` is unset the system will use half the number of available VCPUS to -# compute the number of api workers to use. -# repo_nginx_threads: 16 +## Cap the maximum number of threads / workers when a user value is unspecified. +repo_nginx_threads_max: 16 +repo_nginx_threads: "{{ [[ansible_processor_vcpus|default(2) // 2, 1] | max, repo_nginx_threads_max] | min }}" ## APT Cache Options cache_timeout: 600 diff --git a/releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml b/releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml new file mode 100644 index 0000000..7a94146 --- /dev/null +++ b/releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml @@ -0,0 +1,5 @@ +--- +features: + - Capping the default value for the variable ``repo_nginx_workers`` to + 16 when the user doesn't configure this variable. Default value is half + the number of vCPUs available on the machine with a capping value of 16. diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 7305277..91092e1 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -1,10 +1,7 @@ user {{ repo_service_user_name }} {{ repo_service_group_name }}; pid {{ repo_nginx_pid }}; -{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %} -{% set api_threads = _api_threads if _api_threads > 0 else 1 %} - -worker_processes {{ repo_nginx_threads | default(api_threads) }}; +worker_processes {{ repo_nginx_threads }}; events { worker_connections {{ repo_worker_connections }};