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
# 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.
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'))
]
import functools
import hashlib
import logging as std_logging
+import multiprocessing
import os
import random
import signal
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