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
This commit is contained in:
Brian Haley 2014-01-30 15:05:49 -05:00 committed by Jakub Libosvar
parent 32ca9c4f5f
commit acc21edca4
3 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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()

View File

@ -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()]
)