From bb9e3f582887e3bfbe3beabbd500ac5bd4f0ff27 Mon Sep 17 00:00:00 2001 From: Ravi Gummadi Date: Fri, 3 Mar 2017 07:44:58 -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. Capping only swift proxy server worker threads when the proxy is in a container. Not capping the remaining swift services' workers because of the performance impact it may cause because of the capping. Change-Id: I12d930552558144ab49fecc0b3776747c1f02166 --- defaults/main.yml | 16 ++++++++++++++-- ..._swift_services_workers-5ac9ecb28f56469f.yaml | 8 ++++++++ templates/proxy-server.conf.j2 | 5 +---- 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/capping_swift_services_workers-5ac9ecb28f56469f.yaml diff --git a/defaults/main.yml b/defaults/main.yml index a7aa4bfe..722c63ae 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -178,6 +178,13 @@ swift_rabbitmq_telemetry_servers: "127.0.0.1" swift_rabbitmq_telemetry_use_ssl: "False" ## General Swift configuration +# We are not capping the default value for these swift variables which define +# the number of worker threads for each of the swift services (except the swift +# proxy workers when proxy is in a container) because of the performace impact +# that may be seen due to capping worker threads for swift services. +# We would like to calculate the default value using vCPUs for good performance +# of swift services. + # If ``swift_account_server_replicator_workers`` is unset the system will use half the number # of available VCPUS to compute the number of api workers to use. # swift_account_server_replicator_workers: 16 @@ -203,8 +210,13 @@ swift_rabbitmq_telemetry_use_ssl: "False" # swift_object_server_workers: 16 # If ``swift_proxy_server_workers`` is unset the system will use half the number -# of available VCPUS to compute the number of api workers to use. -# swift_proxy_server_workers: 16 +# of available VCPUS to compute the number of api workers to use. Capping this +# value at 16 if the swift proxy is in a container and user did not define +# this variable. +swift_proxy_server_workers_max: 16 +swift_proxy_server_workers_not_capped: "{{ [ansible_processor_vcpus|default(2) // 2, 1] | max }}" +swift_proxy_server_workers_capped: "{{ [swift_proxy_server_workers_max, swift_proxy_server_workers_not_capped|int] | min }}" +swift_proxy_server_workers: "{{ (inventory_hostname == physical_host) | ternary(swift_proxy_server_workers_not_capped, swift_proxy_server_workers_capped) }}" # These are the storage addresses used to define the networks for swift storage and replication # These are calculated by the tasks based on the "storage_network" and "replication_network" values diff --git a/releasenotes/notes/capping_swift_services_workers-5ac9ecb28f56469f.yaml b/releasenotes/notes/capping_swift_services_workers-5ac9ecb28f56469f.yaml new file mode 100644 index 00000000..34241cd1 --- /dev/null +++ b/releasenotes/notes/capping_swift_services_workers-5ac9ecb28f56469f.yaml @@ -0,0 +1,8 @@ +--- +features: + - Capping the default value for the variable ``swift_proxy_server_workers`` + to 16 when the user doesn't configure this variable and if the swift proxy + is in a container. Default value is half the number of vCPUs available on + the machine if the swift proxy is not in a container. Default value is half + the number of vCPUs available on the machine with a capping value of 16 + if the proxy is in a container. diff --git a/templates/proxy-server.conf.j2 b/templates/proxy-server.conf.j2 index 2001efe6..29172671 100644 --- a/templates/proxy-server.conf.j2 +++ b/templates/proxy-server.conf.j2 @@ -1,14 +1,11 @@ # {{ 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 bind_ip = 0.0.0.0 bind_port = {{ swift_proxy_port }} -workers = {{ swift_proxy_server_workers | default(api_threads) }} +workers = {{ swift_proxy_server_workers }} user = {{ swift_system_user_name }} log_facility = LOG_LOCAL1