From 24f7d80fba5193b10d67cc3d47c03d29d3d316a6 Mon Sep 17 00:00:00 2001 From: Ravi Gummadi Date: Thu, 23 Feb 2017 01:26:46 -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: I09433117941dcd543775d5c347cb03912c21475c --- defaults/main.yml | 4 ++++ .../notes/capping_horizon_workers-29ecc4893bcc3a4b.yaml | 6 ++++++ templates/openstack_dashboard.conf.j2 | 5 +---- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/capping_horizon_workers-29ecc4893bcc3a4b.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 6d36e740..0c3c27c8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -125,6 +125,10 @@ horizon_disallow_iframe_embed: True # horizon_wsgi_processes: 4 # horizon_wsgi_threads: 4 +## Cap the maximun number of threads / workers when a user value is unspecified. +horizon_wsgi_threads_max: 16 +horizon_wsgi_threads: "{{ [[ansible_processor_vcpus|default(2) // 2, 1] | max, horizon_wsgi_threads_max] | min }}" + ## Horizon SSL horizon_ssl_cert: /etc/ssl/certs/horizon.pem horizon_ssl_key: /etc/ssl/private/horizon.key diff --git a/releasenotes/notes/capping_horizon_workers-29ecc4893bcc3a4b.yaml b/releasenotes/notes/capping_horizon_workers-29ecc4893bcc3a4b.yaml new file mode 100644 index 00000000..1718fdcb --- /dev/null +++ b/releasenotes/notes/capping_horizon_workers-29ecc4893bcc3a4b.yaml @@ -0,0 +1,6 @@ +--- +features: + - Capping the default value for the variables + ``horizon_wsgi_processes`` and ``horizon_wsgi_threads`` 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/openstack_dashboard.conf.j2 b/templates/openstack_dashboard.conf.j2 index e11d7b3b..88fb5d26 100644 --- a/templates/openstack_dashboard.conf.j2 +++ b/templates/openstack_dashboard.conf.j2 @@ -1,8 +1,5 @@ # {{ ansible_managed }} -{% set _wsgi_threads = ansible_processor_vcpus | default(2) // 2 %} -{% set wsgi_threads = _wsgi_threads if _wsgi_threads > 0 else 1 %} - {% if not horizon_external_ssl | bool %} ServerName {{ horizon_server_name }} @@ -36,7 +33,7 @@ {% endif %} WSGIScriptAlias / {{ horizon_lib_wsgi_file }} - WSGIDaemonProcess horizon user={{ horizon_system_user_name }} group={{ horizon_system_group_name }} processes={{ horizon_wsgi_processes | default(wsgi_threads) }} threads={{ horizon_wsgi_threads | default(wsgi_threads) }} python-path={{ horizon_bin | dirname }}/lib/python2.7/site-packages + WSGIDaemonProcess horizon user={{ horizon_system_user_name }} group={{ horizon_system_group_name }} processes={{ horizon_wsgi_processes | default(horizon_wsgi_threads) }} threads={{ horizon_wsgi_threads }} python-path={{ horizon_bin | dirname }}/lib/python2.7/site-packages WSGIProcessGroup horizon WSGIApplicationGroup horizon