From e932c4777d6cae1366c61c1becba1cbddf185378 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 7 Jul 2014 10:43:06 -0700 Subject: [PATCH] Use (# of CPUs) api/conductor workers by default This changes the default number of trove API and conductor 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 Cinder as well. DocImpact: trove_api_workeres and trove_conductor_workers will now be equal to the number of CPUs available by default if not explicitly specified in the trove configuration files. UpgradeImpact: Anyone upgrading to this change that does not have trove_api_workers or trove_conductor_workers specified in the trove configuration files will now be running multiple API and conductor workers by default when they restart the respective trove services. Closes-Bug: #1335284 Change-Id: Id300bbe991436a0f826ea715630669ab5922a6a4 --- etc/trove/trove.conf.sample | 5 +++-- etc/trove/trove.conf.test | 5 +++-- trove/cmd/api.py | 4 +++- trove/cmd/conductor.py | 5 +++-- trove/cmd/fakemode.py | 4 +++- trove/common/cfg.py | 8 ++++++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/etc/trove/trove.conf.sample b/etc/trove/trove.conf.sample index 9fc1529c98..50348a195e 100644 --- a/etc/trove/trove.conf.sample +++ b/etc/trove/trove.conf.sample @@ -11,8 +11,9 @@ bind_host = 0.0.0.0 # Port the bind the API server to bind_port = 8779 -# Number of child processes to run -#trove_api_workers=5 +# Number of workers for the API service. The default will +# be the number of CPUs available. (integer value) +#trove_api_workers=None # The RabbitMQ broker address where a single node is used. # (string value) diff --git a/etc/trove/trove.conf.test b/etc/trove/trove.conf.test index b77a6a4085..3ef007c52e 100644 --- a/etc/trove/trove.conf.test +++ b/etc/trove/trove.conf.test @@ -34,8 +34,9 @@ bind_host = 0.0.0.0 # Port the bind the API server to bind_port = 8779 -# Number of child processes to run -#trove_api_workers=5 +# Number of workers for the API service. The default will +# be the number of CPUs available. (integer value) +#trove_api_workers=None # AMQP Connection info rabbit_password=f7999d1955c5014aa32c diff --git a/trove/cmd/api.py b/trove/cmd/api.py index 55e9ae02f3..89a92624e3 100755 --- a/trove/cmd/api.py +++ b/trove/cmd/api.py @@ -13,12 +13,14 @@ # License for the specific language governing permissions and limitations # under the License. from trove.cmd.common import with_initialize +from trove.openstack.common import processutils @with_initialize def main(CONF): from trove.common import wsgi conf_file = CONF.find_file(CONF.api_paste_config) + workers = CONF.trove_api_workers or processutils.get_worker_count() launcher = wsgi.launch('trove', CONF.bind_port or 8779, conf_file, - workers=CONF.trove_api_workers) + workers=workers) launcher.wait() diff --git a/trove/cmd/conductor.py b/trove/cmd/conductor.py index 0508e51be9..0e8c482814 100755 --- a/trove/cmd/conductor.py +++ b/trove/cmd/conductor.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. from trove.cmd.common import with_initialize +from trove.openstack.common import processutils @with_initialize @@ -23,6 +24,6 @@ def main(conf): topic = conf.conductor_queue server = rpc_service.RpcService(manager=conf.conductor_manager, topic=topic) - launcher = openstack_service.launch(server, - workers=conf.trove_conductor_workers) + workers = conf.trove_conductor_workers or processutils.get_worker_count() + launcher = openstack_service.launch(server, workers=workers) launcher.wait() diff --git a/trove/cmd/fakemode.py b/trove/cmd/fakemode.py index ee83e94a5a..68e012f35e 100755 --- a/trove/cmd/fakemode.py +++ b/trove/cmd/fakemode.py @@ -14,6 +14,7 @@ # under the License. from oslo.config import cfg as openstack_cfg from trove.cmd.common import with_initialize +from trove.openstack.common import processutils opts = [ @@ -57,7 +58,8 @@ def start_fake_taskmanager(conf): def start_server(conf): from trove.common import wsgi conf_file = conf.find_file(conf.api_paste_config) + workers = conf.trove_api_workers or processutils.get_worker_count() launcher = wsgi.launch('trove', conf.bind_port or 8779, conf_file, - workers=conf.trove_api_workers) + workers=workers) start_fake_taskmanager(conf) launcher.wait() diff --git a/trove/common/cfg.py b/trove/common/cfg.py index ca0f2533e7..9b704f5990 100644 --- a/trove/common/cfg.py +++ b/trove/common/cfg.py @@ -122,7 +122,9 @@ common_opts = [ help='Default driver to use for quota checks.'), cfg.StrOpt('taskmanager_queue', default='taskmanager'), cfg.StrOpt('conductor_queue', default='trove-conductor'), - cfg.IntOpt('trove_conductor_workers', default=1), + cfg.IntOpt('trove_conductor_workers', + help="Number of workers for the Conductor service. The default " + "will be the number of CPUs available."), cfg.BoolOpt('use_nova_server_volume', default=False), cfg.BoolOpt('use_heat', default=False), cfg.StrOpt('device_path', default='/dev/vdb'), @@ -154,7 +156,9 @@ common_opts = [ cfg.BoolOpt('trove_security_groups_support', default=True), cfg.StrOpt('trove_security_group_name_prefix', default='SecGroup'), cfg.StrOpt('trove_security_group_rule_cidr', default='0.0.0.0/0'), - cfg.IntOpt('trove_api_workers', default=None), + cfg.IntOpt('trove_api_workers', + help="Number of workers for the API service. The default will " + "be the number of CPUs available."), cfg.IntOpt('usage_sleep_time', default=5, help='Time to sleep during the check active guest.'), cfg.StrOpt('region', default='LOCAL_DEV',