Merge "Increase default metadata_workers, backlog to 4096"

This commit is contained in:
Jenkins 2014-06-16 04:58:19 +00:00 committed by Gerrit Code Review
commit 382795ca1d
3 changed files with 14 additions and 5 deletions

View File

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

View File

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

View File

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