Browse Source

Avoid running periodic processes inside each worker process

The periodic jobs are currently getting registered per each worker
which means that in cases with large number of workers, the APIs
for services such as Heat and Keystone will be hit very hard.

This patch resolves this issue by registering the jobs only to the
main process, ensuring that they run once per instance (or group
of workers).

Closes-Bug: #1702349

Change-Id: If9e13effc14fd35e646d02bb4f568e79786aa958
changes/39/499739/5
Mohammed Naser 4 years ago
committed by Spyros Trigazis (strigazi)
parent
commit
8ce15c4510
  1. 7
      magnum/cmd/conductor.py
  2. 5
      magnum/common/rpc_service.py

7
magnum/cmd/conductor.py

@ -60,4 +60,11 @@ def main():
if not workers:
workers = processutils.get_worker_count()
launcher = service.launch(CONF, server, workers=workers)
# NOTE(mnaser): We create the periodic tasks here so that they
# can be attached to the main process and not
# duplicated in all the children if multiple
# workers are being used.
server.create_periodic_tasks()
launcher.wait()

5
magnum/common/rpc_service.py

@ -59,11 +59,12 @@ class Service(service.Service):
profiler.setup(binary, CONF.host)
def start(self):
# NOTE(suro-patz): The parent class has created a threadgroup, already
self._server.start()
def create_periodic_tasks(self):
if CONF.periodic_enable:
periodic.setup(CONF, self.tg)
servicegroup.setup(CONF, self.binary, self.tg)
self._server.start()
def stop(self):
if self._server:

Loading…
Cancel
Save