Increase default metadata_workers, backlog to 4096

While deployment tools might want to change the number of workers
to match the number of cores (Or some fraction of it), any default
other than 1 should be outright better.

Inspired from 19:34:
https://www.youtube.com/watch?v=AF9r_VQrcJ0

DocImpact
Closes-Bug: #1323005
Change-Id: Ie90000183ae67ff391a23ca3213fd23aef5f4dc5
This commit is contained in:
Assaf Muller 2014-05-25 17:01:32 +03:00
parent 2cd747021a
commit 35123c3469
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

@ -306,11 +306,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