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