From: Matt Riedemann Date: Fri, 27 Jun 2014 17:57:33 +0000 (-0700) Subject: Use (# of CPUs) osapi_volume_workers by default X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6f24ca2496e37f3f75496c0e4191e71e55fd7b5d;p=openstack-build%2Fcinder-build.git Use (# of CPUs) osapi_volume_workers by default This changes the default number of cinder API workers to be equal to the number of CPUs available on the host, rather than defaulting to 1 as it did before. Commit 75c96a48fc7e5dfb59d8258142b01422f81b0253 did the same thing in Nova in Icehouse. Similar changes are being made to Glance and Trove as well. DocImpact: osapi_volume_workers will now be equal to the number of CPUs available by default if not explicitly specified in cinder.conf. UpgradeImpact: Anyone upgrading to this change that does not have osapi_volume_workers specified in cinder.conf will now be running multiple API workers by default when they restart the cinder-api service. Closes-Bug: #1333370 Change-Id: I8dec104800c18618e0c8422bbb93d5dc19c12876 --- diff --git a/bin/cinder-api b/bin/cinder-api index 8990f641e..bb203447a 100755 --- a/bin/cinder-api +++ b/bin/cinder-api @@ -55,5 +55,5 @@ if __name__ == '__main__': rpc.init(CONF) launcher = service.process_launcher() server = service.WSGIService('osapi_volume') - launcher.launch_service(server, workers=server.workers or 1) + launcher.launch_service(server, workers=server.workers) launcher.wait() diff --git a/cinder/service.py b/cinder/service.py index 2c00d5c68..53530e112 100755 --- a/cinder/service.py +++ b/cinder/service.py @@ -31,6 +31,7 @@ from cinder import exception from cinder.openstack.common import importutils from cinder.openstack.common import log as logging from cinder.openstack.common import loopingcall +from cinder.openstack.common import processutils from cinder.openstack.common import service from cinder import rpc from cinder import version @@ -59,8 +60,8 @@ service_opts = [ default=8776, help='Port on which OpenStack Volume API listens'), cfg.IntOpt('osapi_volume_workers', - default=1, - help='Number of workers for OpenStack Volume API service'), ] + help='Number of workers for OpenStack Volume API service. ' + 'The default is equal to the number of CPUs available.'), ] CONF = cfg.CONF CONF.register_opts(service_opts) @@ -292,13 +293,14 @@ class WSGIService(object): self.app = self.loader.load_app(name) self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0") self.port = getattr(CONF, '%s_listen_port' % name, 0) - self.workers = getattr(CONF, '%s_workers' % name, None) + self.workers = getattr(CONF, '%s_workers' % name, + processutils.get_worker_count()) if self.workers < 1: LOG.warn(_("Value of config option %(name)s_workers must be " "integer greater than 1. Input value ignored.") % {'name': name}) # Reset workers to default - self.workers = None + self.workers = processutils.get_worker_count() self.server = wsgi.Server(name, self.app, host=self.host, diff --git a/etc/cinder/cinder.conf.sample b/etc/cinder/cinder.conf.sample index 12cb0dfe0..7202dfa8a 100644 --- a/etc/cinder/cinder.conf.sample +++ b/etc/cinder/cinder.conf.sample @@ -272,9 +272,10 @@ # Port on which OpenStack Volume API listens (integer value) #osapi_volume_listen_port=8776 -# Number of workers for OpenStack Volume API service (integer +# Number of workers for OpenStack Volume API service. The +# default is equal to the number of CPUs available. (integer # value) -#osapi_volume_workers=1 +#osapi_volume_workers= #