From ee219bdd383500e511c563b6944fd5ab60c256be Mon Sep 17 00:00:00 2001 From: Tom Haddon Date: Wed, 18 Jun 2014 11:18:02 +0100 Subject: [PATCH] Make the number of workers for account, container and object servers a multiplier of the number of CPUs, and default to a sensible setting per recommendations in http://docs.openstack.org/developer/swift/deployment_guide.html#general-service-tuning --- config.yaml | 7 ++++++- hooks/swift_storage_context.py | 3 +++ hooks/swift_storage_utils.py | 2 +- templates/account-server.conf | 2 +- templates/container-server.conf | 2 +- templates/object-server.conf | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/config.yaml b/config.yaml index a8755f2..f47c150 100644 --- a/config.yaml +++ b/config.yaml @@ -49,4 +49,9 @@ options: default: 6002 type: int description: Listening port of the swift-account-server. - + worker-multiplier: + default: 1 + type: int + description: | + The CPU multiplier to use when configuring worker processes for the + account, container and object server processes. diff --git a/hooks/swift_storage_context.py b/hooks/swift_storage_context.py index 9422234..678fc47 100644 --- a/hooks/swift_storage_context.py +++ b/hooks/swift_storage_context.py @@ -61,10 +61,13 @@ class SwiftStorageServerContext(OSContextGenerator): interfaces = [] def __call__(self): + import psutil + multiplier = config('worker-multiplier') or 1 ctxt = { 'local_ip': unit_private_ip(), 'account_server_port': config('account-server-port'), 'container_server_port': config('container-server-port'), 'object_server_port': config('object-server-port'), + 'workers': psutil.NUM_CPUS * multiplier, } return ctxt diff --git a/hooks/swift_storage_utils.py b/hooks/swift_storage_utils.py index df3265e..9885322 100644 --- a/hooks/swift_storage_utils.py +++ b/hooks/swift_storage_utils.py @@ -48,7 +48,7 @@ from charmhelpers.contrib.openstack import ( PACKAGES = [ 'swift', 'swift-account', 'swift-container', 'swift-object', - 'xfsprogs', 'gdisk', 'lvm2', 'python-jinja2', + 'xfsprogs', 'gdisk', 'lvm2', 'python-jinja2', 'python-psutil', ] TEMPLATES = 'templates/' diff --git a/templates/account-server.conf b/templates/account-server.conf index 0aac9b6..c732f29 100644 --- a/templates/account-server.conf +++ b/templates/account-server.conf @@ -1,7 +1,7 @@ [DEFAULT] bind_ip = 0.0.0.0 bind_port = {{ account_server_port }} -workers = 2 +workers = {{ workers }} [pipeline:main] pipeline = recon account-server diff --git a/templates/container-server.conf b/templates/container-server.conf index ce2c0bb..4753fee 100644 --- a/templates/container-server.conf +++ b/templates/container-server.conf @@ -1,7 +1,7 @@ [DEFAULT] bind_ip = 0.0.0.0 bind_port = {{ container_server_port }} -workers = 2 +workers = {{ workers }} [pipeline:main] pipeline = recon container-server diff --git a/templates/object-server.conf b/templates/object-server.conf index 237be63..ef18461 100644 --- a/templates/object-server.conf +++ b/templates/object-server.conf @@ -1,7 +1,7 @@ [DEFAULT] bind_ip = 0.0.0.0 bind_port = {{ object_server_port }} -workers = 2 +workers = {{ workers }} [pipeline:main] pipeline = recon object-server