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
1=== modified file 'config.yaml'
2--- config.yaml 2012-12-19 23:09:13 +0000
3+++ config.yaml 2014-06-18 11:34:26 +0000
4@@ -49,4 +49,17 @@
5 default: 6002
6 type: int
7 description: Listening port of the swift-account-server.
8-
9+ worker-multiplier:
10+ default: 1
11+ type: int
12+ description: |
13+ The CPU multiplier to use when configuring worker processes for the
14+ account, container and object server processes.
15+ object-server-threads-per-disk:
16+ default: 4
17+ type: int
18+ description: |
19+ Size of the per-disk thread pool used for performing disk I/O. 0 means
20+ to not use a per-disk thread pool. It is recommended to keep this value
21+ small, as large values can result in high read latencies due to large
22+ queue depths. A good starting point is 4 threads per disk.
23
24=== modified file 'hooks/swift_storage_context.py'
25--- hooks/swift_storage_context.py 2013-08-16 20:38:32 +0000
26+++ hooks/swift_storage_context.py 2014-06-18 11:34:26 +0000
27@@ -61,10 +61,15 @@
28 interfaces = []
29
30 def __call__(self):
31+ import psutil
32+ multiplier = int(config('worker-multiplier')) or 1
33 ctxt = {
34 'local_ip': unit_private_ip(),
35 'account_server_port': config('account-server-port'),
36 'container_server_port': config('container-server-port'),
37 'object_server_port': config('object-server-port'),
38+ 'workers': str(psutil.NUM_CPUS * multiplier),
39+ 'object_server_threads_per_disk': config(
40+ 'object-server-threads-per-disk'),
41 }
42 return ctxt
43
44=== modified file 'hooks/swift_storage_utils.py'
45--- hooks/swift_storage_utils.py 2014-05-23 18:35:14 +0000
46+++ hooks/swift_storage_utils.py 2014-06-18 11:34:26 +0000
47@@ -48,7 +48,7 @@
48
49 PACKAGES = [
50 'swift', 'swift-account', 'swift-container', 'swift-object',
51- 'xfsprogs', 'gdisk', 'lvm2', 'python-jinja2',
52+ 'xfsprogs', 'gdisk', 'lvm2', 'python-jinja2', 'python-psutil',
53 ]
54
55 TEMPLATES = 'templates/'
56
57=== modified file 'templates/account-server.conf'
58--- templates/account-server.conf 2013-09-30 13:29:32 +0000
59+++ templates/account-server.conf 2014-06-18 11:34:26 +0000
60@@ -1,7 +1,7 @@
61 [DEFAULT]
62 bind_ip = 0.0.0.0
63 bind_port = {{ account_server_port }}
64-workers = 2
65+workers = {{ workers }}
66
67 [pipeline:main]
68 pipeline = recon account-server
69
70=== modified file 'templates/container-server.conf'
71--- templates/container-server.conf 2014-04-02 12:49:56 +0000
72+++ templates/container-server.conf 2014-06-18 11:34:26 +0000
73@@ -1,7 +1,7 @@
74 [DEFAULT]
75 bind_ip = 0.0.0.0
76 bind_port = {{ container_server_port }}
77-workers = 2
78+workers = {{ workers }}
79
80 [pipeline:main]
81 pipeline = recon container-server
82
83=== modified file 'templates/object-server.conf'
84--- templates/object-server.conf 2013-09-30 13:29:32 +0000
85+++ templates/object-server.conf 2014-06-18 11:34:26 +0000
86@@ -1,7 +1,7 @@
87 [DEFAULT]
88 bind_ip = 0.0.0.0
89 bind_port = {{ object_server_port }}
90-workers = 2
91+workers = {{ workers }}
92
93 [pipeline:main]
94 pipeline = recon object-server
95@@ -12,6 +12,7 @@
96
97 [app:object-server]
98 use = egg:swift#object
99+threads_per_disk = {{ object_server_threads_per_disk }}
100
101 [object-replicator]
102
103
104=== modified file 'unit_tests/test_swift_storage_context.py'
105--- unit_tests/test_swift_storage_context.py 2013-09-27 16:33:06 +0000
106+++ unit_tests/test_swift_storage_context.py 2014-06-18 11:34:26 +0000
107@@ -56,16 +56,22 @@
108 _file.write.assert_called_with('RSYNC_ENABLE=true\n')
109
110 def test_swift_storage_server_context(self):
111+ import psutil
112 self.unit_private_ip.return_value = '10.0.0.5'
113 self.test_config.set('account-server-port', '500')
114 self.test_config.set('object-server-port', '501')
115 self.test_config.set('container-server-port', '502')
116+ self.test_config.set('object-server-threads-per-disk', '3')
117+ self.test_config.set('worker-multiplier', '3')
118+ num_workers = psutil.NUM_CPUS * 3
119 ctxt = swift_context.SwiftStorageServerContext()
120 result = ctxt()
121 ex = {
122 'container_server_port': '502',
123 'object_server_port': '501',
124 'account_server_port': '500',
125- 'local_ip': '10.0.0.5'
126+ 'local_ip': '10.0.0.5',
127+ 'object_server_threads_per_disk': '3',
128+ 'workers': str(num_workers),
129 }
130 self.assertEquals(ex, result)

Subscribers

People subscribed via source and target branches