Merge lp:~mthaddon/charms/trusty/swift-storage/workers-cpu-scaling into lp:~openstack-charmers-archive/charms/trusty/swift-storage/next

Proposed by Tom Haddon
Status: Merged
Merged at revision: 31
Proposed branch: lp:~mthaddon/charms/trusty/swift-storage/workers-cpu-scaling
Merge into: lp:~openstack-charmers-archive/charms/trusty/swift-storage/next
Diff against target: 130 lines (+31/-6)
7 files modified
config.yaml (+14/-1)
hooks/swift_storage_context.py (+5/-0)
hooks/swift_storage_utils.py (+1/-1)
templates/account-server.conf (+1/-1)
templates/container-server.conf (+1/-1)
templates/object-server.conf (+2/-1)
unit_tests/test_swift_storage_context.py (+7/-1)
To merge this branch: bzr merge lp:~mthaddon/charms/trusty/swift-storage/workers-cpu-scaling
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Review via email: mp+223534@code.launchpad.net

Description of the change

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. Also, add in a tunable option for object server threads_per_disk and tune default to recommendations from http://docs.openstack.org/developer/swift/deployment_guide.html#object-server-configuration.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

Hi Tom

Thanks for the MP - looks like a good feature to have.

Right now this branch introduces a test failure:

======================================================================
FAIL: test_swift_storage_server_context (unit_tests.test_swift_storage_context.SwiftStorageContextTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jamespage/src/charms/review/swift-storage/unit_tests/test_swift_storage_context.py", line 71, in test_swift_storage_server_context
    self.assertEquals(ex, result)
AssertionError: {'container_server_port': '502', 'local_ip': '10.0.0.5', 'account_server_port': [truncated]... != {'local_ip': '10.0.0.5', 'workers': 4, 'object_server_threads_per_disk': 4, 'con [truncated]...
  {'account_server_port': '500',
   'container_server_port': '502',
   'local_ip': '10.0.0.5',
- 'object_server_port': '501'}
? ^

+ 'object_server_port': '501',
? ^

+ 'object_server_threads_per_disk': 4,
+ 'workers': 4}

Please could you fix up - you can run units tests by using 'make test'. You will need to patch out psutils.NUM_CPU's as well in order to make the test deterministic.

Cheers

James

review: Needs Fixing
32. By Tom Haddon

Unit tests for the new worker multiplier and threads per disk config values

Revision history for this message
Tom Haddon (mthaddon) wrote :

I've updated this to fix the tests. I've converted the "workers" variable to a string in both the unit tests and the SwiftStorageServerContext class, as that seems to match what we have for the other values.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2012-12-19 23:09:13 +0000
+++ config.yaml 2014-06-18 11:34:26 +0000
@@ -49,4 +49,17 @@
49 default: 600249 default: 6002
50 type: int50 type: int
51 description: Listening port of the swift-account-server.51 description: Listening port of the swift-account-server.
5252 worker-multiplier:
53 default: 1
54 type: int
55 description: |
56 The CPU multiplier to use when configuring worker processes for the
57 account, container and object server processes.
58 object-server-threads-per-disk:
59 default: 4
60 type: int
61 description: |
62 Size of the per-disk thread pool used for performing disk I/O. 0 means
63 to not use a per-disk thread pool. It is recommended to keep this value
64 small, as large values can result in high read latencies due to large
65 queue depths. A good starting point is 4 threads per disk.
5366
=== modified file 'hooks/swift_storage_context.py'
--- hooks/swift_storage_context.py 2013-08-16 20:38:32 +0000
+++ hooks/swift_storage_context.py 2014-06-18 11:34:26 +0000
@@ -61,10 +61,15 @@
61 interfaces = []61 interfaces = []
6262
63 def __call__(self):63 def __call__(self):
64 import psutil
65 multiplier = int(config('worker-multiplier')) or 1
64 ctxt = {66 ctxt = {
65 'local_ip': unit_private_ip(),67 'local_ip': unit_private_ip(),
66 'account_server_port': config('account-server-port'),68 'account_server_port': config('account-server-port'),
67 'container_server_port': config('container-server-port'),69 'container_server_port': config('container-server-port'),
68 'object_server_port': config('object-server-port'),70 'object_server_port': config('object-server-port'),
71 'workers': str(psutil.NUM_CPUS * multiplier),
72 'object_server_threads_per_disk': config(
73 'object-server-threads-per-disk'),
69 }74 }
70 return ctxt75 return ctxt
7176
=== modified file 'hooks/swift_storage_utils.py'
--- hooks/swift_storage_utils.py 2014-05-23 18:35:14 +0000
+++ hooks/swift_storage_utils.py 2014-06-18 11:34:26 +0000
@@ -48,7 +48,7 @@
4848
49PACKAGES = [49PACKAGES = [
50 'swift', 'swift-account', 'swift-container', 'swift-object',50 'swift', 'swift-account', 'swift-container', 'swift-object',
51 'xfsprogs', 'gdisk', 'lvm2', 'python-jinja2',51 'xfsprogs', 'gdisk', 'lvm2', 'python-jinja2', 'python-psutil',
52]52]
5353
54TEMPLATES = 'templates/'54TEMPLATES = 'templates/'
5555
=== modified file 'templates/account-server.conf'
--- templates/account-server.conf 2013-09-30 13:29:32 +0000
+++ templates/account-server.conf 2014-06-18 11:34:26 +0000
@@ -1,7 +1,7 @@
1[DEFAULT]1[DEFAULT]
2bind_ip = 0.0.0.02bind_ip = 0.0.0.0
3bind_port = {{ account_server_port }}3bind_port = {{ account_server_port }}
4workers = 24workers = {{ workers }}
55
6[pipeline:main]6[pipeline:main]
7pipeline = recon account-server7pipeline = recon account-server
88
=== modified file 'templates/container-server.conf'
--- templates/container-server.conf 2014-04-02 12:49:56 +0000
+++ templates/container-server.conf 2014-06-18 11:34:26 +0000
@@ -1,7 +1,7 @@
1[DEFAULT]1[DEFAULT]
2bind_ip = 0.0.0.02bind_ip = 0.0.0.0
3bind_port = {{ container_server_port }}3bind_port = {{ container_server_port }}
4workers = 24workers = {{ workers }}
55
6[pipeline:main]6[pipeline:main]
7pipeline = recon container-server7pipeline = recon container-server
88
=== modified file 'templates/object-server.conf'
--- templates/object-server.conf 2013-09-30 13:29:32 +0000
+++ templates/object-server.conf 2014-06-18 11:34:26 +0000
@@ -1,7 +1,7 @@
1[DEFAULT]1[DEFAULT]
2bind_ip = 0.0.0.02bind_ip = 0.0.0.0
3bind_port = {{ object_server_port }}3bind_port = {{ object_server_port }}
4workers = 24workers = {{ workers }}
55
6[pipeline:main]6[pipeline:main]
7pipeline = recon object-server7pipeline = recon object-server
@@ -12,6 +12,7 @@
1212
13[app:object-server]13[app:object-server]
14use = egg:swift#object14use = egg:swift#object
15threads_per_disk = {{ object_server_threads_per_disk }}
1516
16[object-replicator]17[object-replicator]
1718
1819
=== modified file 'unit_tests/test_swift_storage_context.py'
--- unit_tests/test_swift_storage_context.py 2013-09-27 16:33:06 +0000
+++ unit_tests/test_swift_storage_context.py 2014-06-18 11:34:26 +0000
@@ -56,16 +56,22 @@
56 _file.write.assert_called_with('RSYNC_ENABLE=true\n')56 _file.write.assert_called_with('RSYNC_ENABLE=true\n')
5757
58 def test_swift_storage_server_context(self):58 def test_swift_storage_server_context(self):
59 import psutil
59 self.unit_private_ip.return_value = '10.0.0.5'60 self.unit_private_ip.return_value = '10.0.0.5'
60 self.test_config.set('account-server-port', '500')61 self.test_config.set('account-server-port', '500')
61 self.test_config.set('object-server-port', '501')62 self.test_config.set('object-server-port', '501')
62 self.test_config.set('container-server-port', '502')63 self.test_config.set('container-server-port', '502')
64 self.test_config.set('object-server-threads-per-disk', '3')
65 self.test_config.set('worker-multiplier', '3')
66 num_workers = psutil.NUM_CPUS * 3
63 ctxt = swift_context.SwiftStorageServerContext()67 ctxt = swift_context.SwiftStorageServerContext()
64 result = ctxt()68 result = ctxt()
65 ex = {69 ex = {
66 'container_server_port': '502',70 'container_server_port': '502',
67 'object_server_port': '501',71 'object_server_port': '501',
68 'account_server_port': '500',72 'account_server_port': '500',
69 'local_ip': '10.0.0.5'73 'local_ip': '10.0.0.5',
74 'object_server_threads_per_disk': '3',
75 'workers': str(num_workers),
70 }76 }
71 self.assertEquals(ex, result)77 self.assertEquals(ex, result)

Subscribers

People subscribed via source and target branches