From fe6629dfc9b2f85c424a2aa0ff3cc43d8ebc005c Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Thu, 30 Jan 2014 15:05:49 -0500 Subject: [PATCH] Change metadata-agent to have a configurable backlog The metadata agent currently runs with a default socket backlog of 128. This isn't enough on a busy network node, even when spawning multiple worker processes. This change addes a new "metadata_backlog = XX" to the ini file to support a configurable value to help improve performance. Change-Id: Ibea398f3b65a56deb1418f39810d87d8360ea9f3 Closes-bug: #1274536 --- etc/metadata_agent.ini | 3 +++ neutron/agent/metadata/agent.py | 11 ++++++++--- neutron/tests/unit/test_metadata_agent.py | 8 +++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/etc/metadata_agent.ini b/etc/metadata_agent.ini index 98a0b5053..38909233e 100644 --- a/etc/metadata_agent.ini +++ b/etc/metadata_agent.ini @@ -29,3 +29,6 @@ admin_password = %SERVICE_PASSWORD% # Number of separate worker processes for metadata server # metadata_workers = 0 + +# Number of backlog requests to configure the metadata server socket with +# metadata_backlog = 128 diff --git a/neutron/agent/metadata/agent.py b/neutron/agent/metadata/agent.py index 699aa59ce..c8d618739 100644 --- a/neutron/agent/metadata/agent.py +++ b/neutron/agent/metadata/agent.py @@ -207,7 +207,7 @@ class UnixDomainWSGIServer(wsgi.Server): self._server = None super(UnixDomainWSGIServer, self).__init__(name) - def start(self, application, file_socket, workers, backlog=128): + def start(self, application, file_socket, workers, backlog): self._socket = eventlet.listen(file_socket, family=socket.AF_UNIX, backlog=backlog) @@ -240,7 +240,11 @@ class UnixDomainMetadataProxy(object): cfg.IntOpt('metadata_workers', default=0, help=_('Number of separate worker processes for metadata ' - 'server')) + 'server')), + cfg.IntOpt('metadata_backlog', + default=128, + help=_('Number of backlog requests to configure the ' + 'metadata server socket with')) ] def __init__(self, conf): @@ -299,7 +303,8 @@ class UnixDomainMetadataProxy(object): server = UnixDomainWSGIServer('neutron-metadata-agent') server.start(MetadataProxyHandler(self.conf), self.conf.metadata_proxy_socket, - workers=self.conf.metadata_workers) + workers=self.conf.metadata_workers, + backlog=self.conf.metadata_backlog) server.wait() diff --git a/neutron/tests/unit/test_metadata_agent.py b/neutron/tests/unit/test_metadata_agent.py index 3437bbbd4..7b5fab2c1 100644 --- a/neutron/tests/unit/test_metadata_agent.py +++ b/neutron/tests/unit/test_metadata_agent.py @@ -275,7 +275,7 @@ class TestUnixDomainWSGIServer(base.BaseTestCase): def test_start(self): mock_app = mock.Mock() with mock.patch.object(self.server, 'pool') as pool: - self.server.start(mock_app, '/the/path', workers=0) + self.server.start(mock_app, '/the/path', workers=0, backlog=128) self.eventlet.assert_has_calls([ mock.call.listen( '/the/path', @@ -294,7 +294,7 @@ class TestUnixDomainWSGIServer(base.BaseTestCase): launcher = process_launcher.return_value mock_app = mock.Mock() - self.server.start(mock_app, '/the/path', workers=2) + self.server.start(mock_app, '/the/path', workers=2, backlog=128) launcher.running = True launcher.launch_service.assert_called_once_with(self.server._server, workers=2) @@ -330,6 +330,7 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): self.addCleanup(mock.patch.stopall) self.cfg.CONF.metadata_proxy_socket = '/the/path' self.cfg.CONF.metadata_workers = 0 + self.cfg.CONF.metadata_backlog = 128 def test_init_doesnot_exists(self): with mock.patch('os.path.isdir') as isdir: @@ -393,7 +394,8 @@ class TestUnixDomainMetadataProxy(base.BaseTestCase): server.assert_has_calls([ mock.call('neutron-metadata-agent'), mock.call().start(handler.return_value, - '/the/path', workers=0), + '/the/path', workers=0, + backlog=128), mock.call().wait()] ) -- 2.45.2