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
This commit is contained in:
Mohammed Naser 2017-08-31 13:15:26 -04:00 committed by Spyros Trigazis (strigazi)
parent bbe6757801
commit 8ce15c4510
2 changed files with 10 additions and 2 deletions

View File

@ -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()

View File

@ -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: