From c18d9704affafd19876e65d326ec27fc129604c3 Mon Sep 17 00:00:00 2001 From: Ravi Gummadi Date: Thu, 23 Feb 2017 00:40:42 -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: Ibd293f102bc0201d5d451549d37458bef352d930 --- defaults/main.yml | 4 ++++ .../notes/capping_glance_workers-54afc20c20baa14e.yaml | 6 ++++++ templates/glance-api.conf.j2 | 5 +---- templates/glance-registry.conf.j2 | 5 +---- 4 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/capping_glance_workers-54afc20c20baa14e.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 5e6fca9c..3fc8aaa7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -151,6 +151,10 @@ glance_image_cache_max_size: 10737418240 # compute the number of api workers to use. # glance_registry_workers: 16 +## Cap the maximum number of threads / workers when a user value is unspecified. +glance_api_threads_max: 16 +glance_api_threads: "{{ [[ansible_processor_vcpus|default(2) // 2, 1] | max, glance_api_threads_max] | min }}" + glance_task_executor: taskflow glance_digest_algorithm: sha256 glance_http_keepalive: True diff --git a/releasenotes/notes/capping_glance_workers-54afc20c20baa14e.yaml b/releasenotes/notes/capping_glance_workers-54afc20c20baa14e.yaml new file mode 100644 index 00000000..deb5354a --- /dev/null +++ b/releasenotes/notes/capping_glance_workers-54afc20c20baa14e.yaml @@ -0,0 +1,6 @@ +--- +features: + - Capping the default value for the variables ``glance_api_workers`` and + ``glance_registry_workers`` to 16 when the user doesn't configure + these variables. Default value is half the number of vCPUs available + on the machine with a capping value of 16. diff --git a/templates/glance-api.conf.j2 b/templates/glance-api.conf.j2 index d42b3acd..5b9844d6 100644 --- a/templates/glance-api.conf.j2 +++ b/templates/glance-api.conf.j2 @@ -1,8 +1,5 @@ # {{ ansible_managed }} -{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %} -{% set api_threads = _api_threads if _api_threads > 0 else 1 %} - [DEFAULT] # Disable stderr logging use_stderr = False @@ -14,7 +11,7 @@ bind_port = {{ glance_api_service_port }} http_keepalive = {{ glance_http_keepalive }} digest_algorithm = {{ glance_digest_algorithm }} backlog = 4096 -workers = {{ glance_api_workers | default(api_threads) }} +workers = {{ glance_api_workers | default(glance_api_threads) }} registry_host = {{ glance_registry_host }} registry_port = {{ glance_registry_service_port }} registry_client_protocol = {{ glance_service_registry_proto }} diff --git a/templates/glance-registry.conf.j2 b/templates/glance-registry.conf.j2 index 77b00200..9c9573c4 100644 --- a/templates/glance-registry.conf.j2 +++ b/templates/glance-registry.conf.j2 @@ -1,8 +1,5 @@ # {{ ansible_managed }} -{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %} -{% set api_threads = _api_threads if _api_threads > 0 else 1 %} - [DEFAULT] # Disable stderr logging use_stderr = False @@ -13,7 +10,7 @@ bind_host = {{ glance_registry_bind_address }} bind_port = {{ glance_registry_service_port }} http_keepalive = {{ glance_http_keepalive }} backlog = 4096 -workers = {{ glance_registry_workers | default(api_threads) }} +workers = {{ glance_registry_workers | default(glance_api_threads) }} api_limit_max = 1000 limit_param_default = 25