From 09b717c04bb9d0a91da91352d5903daed5c75b36 Mon Sep 17 00:00:00 2001 From: Morgan Fainberg Date: Thu, 18 Sep 2014 11:02:31 -0700 Subject: [PATCH] Set the default number of workers when running under eventlet Keystone now defaults to n-cpu as the number of workers under eventlet with a minimum number of workers when auto-calculating the number of 2. This behavior can be overridded by changing the `admin_workers` and `public_workers` configuration values in the Keystone config file. Change-Id: I482cfef7ee14e995c6fb206bcef412957c54f491 Closes-Bug: #1371154 --- bin/keystone-all | 17 +++++++++++++++-- etc/keystone.conf.sample | 20 +++++++++++++------- keystone/common/config.py | 10 ++++++---- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/bin/keystone-all b/bin/keystone-all index 8f31e01b4b..89e5128d6a 100755 --- a/bin/keystone-all +++ b/bin/keystone-all @@ -47,6 +47,7 @@ from keystone.common import sql from keystone.common import utils from keystone import config from keystone.i18n import _ +from keystone.openstack.common import processutils from keystone.openstack.common import service from keystone.openstack.common import systemd from keystone import service as keystone_service @@ -104,6 +105,15 @@ def serve(*servers): launcher.wait() +def _get_workers(worker_type_config_opt): + # Get the value from config, if the config value is None (not set), return + # the number of cpus with a minimum of 2. + worker_count = CONF.get(worker_type_config_opt) + if not worker_count: + worker_count = max(2, processutils.get_worker_count()) + return worker_count + + if __name__ == '__main__': dev_conf = os.path.join(possible_topdir, 'etc', @@ -136,17 +146,20 @@ if __name__ == '__main__': backends.load_backends() + admin_worker_count = _get_workers('admin_workers') + public_worker_count = _get_workers('public_workers') + servers = [] servers.append(create_server(paste_config, 'admin', CONF.admin_bind_host, int(CONF.admin_port), - CONF.admin_workers)) + admin_worker_count)) servers.append(create_server(paste_config, 'main', CONF.public_bind_host, int(CONF.public_port), - CONF.public_workers)) + public_worker_count)) dependency.resolve_future_dependencies() serve(*servers) diff --git a/etc/keystone.conf.sample b/etc/keystone.conf.sample index 27a00ec426..cfd970ac62 100644 --- a/etc/keystone.conf.sample +++ b/etc/keystone.conf.sample @@ -60,12 +60,14 @@ #admin_endpoint= # The number of worker processes to serve the public WSGI -# application (integer value) -#public_workers=1 +# application. Defaults to number of CPUs (minimum of 2). +# (integer value) +#public_workers= # The number of worker processes to serve the admin WSGI -# application (integer value) -#admin_workers=1 +# application. Defaults to number of CPUs (minimum of 2). +# (integer value) +#admin_workers= # Enforced by optional sizelimit middleware # (keystone.middleware:RequestBodySizeLimiter). (integer @@ -172,6 +174,10 @@ # Whether to disable the Nagle algorithm. (boolean value) #qpid_tcp_nodelay=true +# The number of prefetched messages held by receiver. (integer +# value) +#qpid_receiver_capacity=1 + # The qpid topology version to use. Version 1 is what was # originally used by impl_qpid. Version 2 includes some # backwards-incompatible changes that allow broker federation @@ -1281,7 +1287,7 @@ # backend. (integer value) #expiration_buffer=1800 -# Toggle for revocation event cacheing. This has no effect +# Toggle for revocation event caching. This has no effect # unless global caching is enabled. (boolean value) #caching=true @@ -1476,13 +1482,13 @@ # Controls the token construction, validation, and revocation # operations. Core providers are # "keystone.token.providers.[pkiz|pki|uuid].Provider". The -# default provider is pkiz. (string value) +# default provider is uuid. (string value) #provider= # Token persistence backend driver. (string value) #driver=keystone.token.persistence.backends.sql.Token -# Toggle for token system cacheing. This has no effect unless +# Toggle for token system caching. This has no effect unless # global caching is enabled. (boolean value) #caching=true diff --git a/keystone/common/config.py b/keystone/common/config.py index 4b06b53958..fee1fe525d 100644 --- a/keystone/common/config.py +++ b/keystone/common/config.py @@ -77,12 +77,14 @@ FILE_OPTIONS = { 'to set this value if the base URL contains a path ' '(e.g. /prefix/v2.0) or the endpoint should be found ' 'on a different server.'), - cfg.IntOpt('public_workers', default=1, + cfg.IntOpt('public_workers', help='The number of worker processes to serve the public ' - 'WSGI application'), - cfg.IntOpt('admin_workers', default=1, + 'WSGI application. Defaults to number of CPUs ' + '(minimum of 2).'), + cfg.IntOpt('admin_workers', help='The number of worker processes to serve the admin ' - 'WSGI application'), + 'WSGI application. Defaults to number of CPUs ' + '(minimum of 2).'), # default max request size is 112k cfg.IntOpt('max_request_body_size', default=114688, help='Enforced by optional sizelimit middleware '