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