From 61d149c0123997accc5c48994d7a4d1514eb49c9 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Aug 2019 20:37:09 +0100 Subject: [PATCH] Fix default RPC worker count The help for the rpc_workers config option is: Number of RPC worker processes for service. If not specified, the default is equal to half the number of API workers. However, this does not accurately describe the current behaviour, which is to default to half the _default_ number of API workers. This can make a big difference; for example on a 256-CPU machine with 256GB of RAM which has api_workers configured to 8 but rpc_workers not configured to anything, this will result in 64 RPC workers, which is 8 for every API worker! Therefore tweak the default to rely on the actual value of api_workers, which may be different than the default value. Change-Id: I26115932ef4775f157297be1637ee26a4fca4666 Related-Bug: #1838688 Closes-Bug: #1838689 --- neutron/service.py | 2 +- neutron/tests/unit/test_service.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/neutron/service.py b/neutron/service.py index 402c69374fd..06bf4cdc7b2 100644 --- a/neutron/service.py +++ b/neutron/service.py @@ -176,7 +176,7 @@ def _get_rpc_workers(plugin=None): workers = cfg.CONF.rpc_workers if workers is None: # By default, half as many rpc workers as api workers - workers = int(_get_worker_count() / 2) + workers = int(_get_api_workers() / 2) if workers < 1: workers = 1 diff --git a/neutron/tests/unit/test_service.py b/neutron/tests/unit/test_service.py index 1e51723e93d..536d85f93ac 100644 --- a/neutron/tests/unit/test_service.py +++ b/neutron/tests/unit/test_service.py @@ -61,9 +61,13 @@ class TestRunRpcWorkers(base.BaseTestCase): def test_rpc_workers_zero(self): self._test_rpc_workers(0, 1) - def test_rpc_workers_default(self): + def test_rpc_workers_default_api_workers_default(self): self._test_rpc_workers(None, int(self.worker_count / 2)) + def test_rpc_workers_default_api_workers_set(self): + cfg.CONF.set_override('api_workers', 18) + self._test_rpc_workers(None, 9) + def test_rpc_workers_defined(self): self._test_rpc_workers(42, 42)