From 600620a8d50fc13f7a9cc4901b0307d09039e7bb Mon Sep 17 00:00:00 2001 From: Yves-Gwenael Bourhis Date: Fri, 20 Jan 2017 11:49:34 +0100 Subject: [PATCH] Configuring number of apache processes By default apache spawns only one process for the wsgi app if not specified. This patch detects the number of CPUS to configure n CPUs +1 processes by default and allows to specify the number of processes explicitly. Change-Id: I684ecd15193cef169d7a86f66a47b7d1d76c1c24 Closes-Bug: #1658048 --- doc/source/topics/install.rst | 7 +++++++ .../management/commands/apache_vhost.conf.template | 2 +- .../management/commands/make_web_conf.py | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/source/topics/install.rst b/doc/source/topics/install.rst index 91104afe65..b3bd643508 100644 --- a/doc/source/topics/install.rst +++ b/doc/source/topics/install.rst @@ -104,6 +104,13 @@ Installation $ ./manage.py make_web_conf --apache --ssl --sslkey=/path/to/ssl/key --sslcert=/path/to/ssl/cert > /etc/apache2/sites-available/horizon.conf + By default the apache configuration will launch a number of apache processes + equal to the number of CPUs + 1 of the machine on which you launch the + make_web_conf command. If the target machine is not the same or if you want + to specify the number of processes, add the --processes option:: + + $ ./manage.py make_web_conf --apache --processes 10 > /etc/apache2/sites-available/horizon.conf + 6. Finally, enable the above configuration and restart the web server:: $ sudo a2ensite horizon diff --git a/openstack_dashboard/management/commands/apache_vhost.conf.template b/openstack_dashboard/management/commands/apache_vhost.conf.template index 06fe27fd6d..2f299bc725 100644 --- a/openstack_dashboard/management/commands/apache_vhost.conf.template +++ b/openstack_dashboard/management/commands/apache_vhost.conf.template @@ -18,7 +18,7 @@ CustomLog {{ LOGDIR }}/{{ PROJECT_NAME }}-access.log combined WSGIScriptReloading On - WSGIDaemonProcess {{ PROJECT_NAME }}_website + WSGIDaemonProcess {{ PROJECT_NAME }}_website processes={{ PROCESSES }} WSGIProcessGroup {{ PROJECT_NAME }}_website WSGIApplicationGroup {{ PROJECT_NAME }}_website WSGIPassAuthorization On diff --git a/openstack_dashboard/management/commands/make_web_conf.py b/openstack_dashboard/management/commands/make_web_conf.py index ce6bd0ea3e..2dda25d0a8 100644 --- a/openstack_dashboard/management/commands/make_web_conf.py +++ b/openstack_dashboard/management/commands/make_web_conf.py @@ -12,6 +12,7 @@ from __future__ import print_function +import multiprocessing import os import re import socket @@ -74,6 +75,7 @@ context = Context({ 'SSLCERT': '/etc/pki/tls/certs/ca.crt', 'SSLKEY': '/etc/pki/tls/private/ca.key', 'CACERT': None, + 'PROCESSES': multiprocessing.cpu_count() + 1, }) context['PROJECT_ROOT'] = os.path.dirname(context['PROJECT_PATH']) @@ -213,6 +215,14 @@ location you desire, e.g.:: "configuration will work only when accessed with " "the proper hostname (see --hostname).") ) + parser.add_argument( + "--processes", + dest="processes", + help=("Use with the --apache option to define the number of " + "apache processes (by default the number of cpus +1 which " + "is %s on this machine).") % context['PROCESSES'], + metavar="PROCESSES" + ) parser.add_argument( "-p", "--project", dest="project", @@ -268,6 +278,8 @@ location you desire, e.g.:: context['CACERT'] = options['cacert'] if options.get('logdir'): context['LOGDIR'] = options['logdir'].rstrip('/') + if options.get('processes'): + context['PROCESSES'] = options['processes'] if options.get('project'): context['PROJECT_NAME'] = options['project'] if options.get('hostname'):