diff --git a/etc/metadata_agent.ini b/etc/metadata_agent.ini index 3da2047532..84442ea1ac 100644 --- a/etc/metadata_agent.ini +++ b/etc/metadata_agent.ini @@ -45,11 +45,12 @@ admin_password = %SERVICE_PASSWORD% # Location of Metadata Proxy UNIX domain socket # metadata_proxy_socket = $state_path/metadata_proxy -# Number of separate worker processes for metadata server -# metadata_workers = 0 +# Number of separate worker processes for metadata server. Defaults to +# half the number of CPU cores +# metadata_workers = # Number of backlog requests to configure the metadata server socket with -# metadata_backlog = 128 +# metadata_backlog = 4096 # URL to connect to the cache backend. # default_ttl=0 parameter will cause cache entries to never expire. diff --git a/neutron/agent/metadata/agent.py b/neutron/agent/metadata/agent.py index 92b5fe08b2..c38e4fe4bf 100644 --- a/neutron/agent/metadata/agent.py +++ b/neutron/agent/metadata/agent.py @@ -307,11 +307,11 @@ class UnixDomainMetadataProxy(object): default='$state_path/metadata_proxy', help=_('Location for Metadata Proxy UNIX domain socket')), cfg.IntOpt('metadata_workers', - default=0, + default=utils.cpu_count() // 2, help=_('Number of separate worker processes for metadata ' 'server')), cfg.IntOpt('metadata_backlog', - default=128, + default=4096, help=_('Number of backlog requests to configure the ' 'metadata server socket with')) ] diff --git a/neutron/common/utils.py b/neutron/common/utils.py index bbb4e3822a..4378218e4d 100644 --- a/neutron/common/utils.py +++ b/neutron/common/utils.py @@ -22,6 +22,7 @@ import datetime import functools import hashlib import logging as std_logging +import multiprocessing import os import random import signal @@ -291,3 +292,10 @@ def get_dhcp_agent_device_id(network_id, host): local_hostname = host.split('.')[0] host_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, str(local_hostname)) return 'dhcp%s-%s' % (host_uuid, network_id) + + +def cpu_count(): + try: + return multiprocessing.cpu_count() + except NotImplementedError: + return 1