From 7da4e498d4713871a287f9c381b6cb0d53213e1e Mon Sep 17 00:00:00 2001
From: Juan Antonio Osorio Robles <jaosorior@redhat.com>
Date: Fri, 13 Oct 2017 08:14:32 +0300
Subject: [PATCH] apache wsgi: Exchange defaults for workers and threads

Due to Python's GIL [1], we can't use multiple threads for running
OpenStack services without a performance penalty, since the execution
ends up serialized, which defeats the purpose.

Instead, we should use several processes, since this approach doesn't
have this limitation.

[1] https://wiki.python.org/moin/GlobalInterpreterLock

Change-Id: I18c1e796e43a168042900b8202ad3ce8488d3908
---
 manifests/wsgi/apache.pp               | 8 ++++----
 spec/classes/zaqar_wsgi_apache_spec.rb | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/manifests/wsgi/apache.pp b/manifests/wsgi/apache.pp
index ba39eb7..db09914 100644
--- a/manifests/wsgi/apache.pp
+++ b/manifests/wsgi/apache.pp
@@ -42,7 +42,7 @@
 #
 #   [*workers*]
 #     Number of WSGI workers to spawn.
-#     Optional. Defaults to 1
+#     Optional. Defaults to $::os_workers
 #
 #   [*priority*]
 #     (optional) The priority for the vhost.
@@ -50,7 +50,7 @@
 #
 #   [*threads*]
 #     (optional) The number of threads for the vhost.
-#     Defaults to $::os_workers
+#     Defaults to 1
 #
 #   [*wsgi_process_display_name*]
 #     (optional) Name of the WSGI process display-name.
@@ -94,7 +94,7 @@ class zaqar::wsgi::apache (
   $bind_host                  = undef,
   $path                       = '/',
   $ssl                        = true,
-  $workers                    = 1,
+  $workers                    = $::os_workers,
   $ssl_cert                   = undef,
   $ssl_key                    = undef,
   $ssl_chain                  = undef,
@@ -103,7 +103,7 @@ class zaqar::wsgi::apache (
   $ssl_crl                    = undef,
   $ssl_certs_dir              = undef,
   $wsgi_process_display_name  = undef,
-  $threads                    = $::os_workers,
+  $threads                    = 1,
   $priority                   = '10',
   $access_log_file            = false,
   $access_log_format          = false,
diff --git a/spec/classes/zaqar_wsgi_apache_spec.rb b/spec/classes/zaqar_wsgi_apache_spec.rb
index dc4d422..b547db0 100644
--- a/spec/classes/zaqar_wsgi_apache_spec.rb
+++ b/spec/classes/zaqar_wsgi_apache_spec.rb
@@ -14,9 +14,9 @@ describe 'zaqar::wsgi::apache' do
         :path                => '/',
         :servername          => facts[:fqdn],
         :ssl                 => true,
-        :threads             => facts[:os_workers],
+        :threads             => 1,
         :user                => 'zaqar',
-        :workers             => 1,
+        :workers             => facts[:os_workers],
         :wsgi_daemon_process => 'zaqar-server',
         :wsgi_process_group  => 'zaqar-server',
         :wsgi_script_dir     => platform_params[:wsgi_script_path],
@@ -52,7 +52,7 @@ describe 'zaqar::wsgi::apache' do
         :path                      => '/',
         :servername                => 'dummy.host',
         :ssl                       => false,
-        :threads                   => facts[:os_workers],
+        :threads                   => 1,
         :user                      => 'zaqar',
         :workers                   => 37,
         :wsgi_daemon_process       => 'zaqar-server',