Disable reverse dns lookup
The BaseHTTPServer will do a reverse dns lookup when log message, which will cause 10 seconds latency in some network environment. This will significantly slow down the api request when wsgiref.simple_server is used. Change-Id: I0c8de84665f9a68290a26874aa555a881e8f1ca2 Closes-Bug: #1291229
This commit is contained in:
parent
31781b60aa
commit
342265f9b8
@ -39,7 +39,13 @@ API_SERVICE_OPTS = [
|
||||
cfg.IntOpt('max_limit',
|
||||
default=1000,
|
||||
help='The maximum number of items returned in a single '
|
||||
'response from a collection resource.')
|
||||
'response from a collection resource.'),
|
||||
cfg.BoolOpt('enable_reverse_dns_lookup',
|
||||
default=False,
|
||||
help=('Set it to False if your environment does not need '
|
||||
'or have dns server, otherwise it will delay the '
|
||||
'response from api.')
|
||||
)
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -30,6 +30,20 @@ from cloudpulse.openstack.common import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_handler_cls():
|
||||
cls = simple_server.WSGIRequestHandler
|
||||
|
||||
class CloudpulseHandler(cls, object):
|
||||
|
||||
def address_string(self):
|
||||
if cfg.CONF.api.enable_reverse_dns_lookup:
|
||||
return super(CloudpulseHandler, self).address_string()
|
||||
else:
|
||||
return self.client_address[0]
|
||||
|
||||
return CloudpulseHandler
|
||||
|
||||
|
||||
def main():
|
||||
service.prepare_service(sys.argv)
|
||||
|
||||
@ -37,7 +51,8 @@ def main():
|
||||
|
||||
# Create the WSGI server and start it
|
||||
host, port = cfg.CONF.host, cfg.CONF.port
|
||||
srv = simple_server.make_server(host, port, app)
|
||||
srv = simple_server.make_server(
|
||||
host, port, app, handler_class=get_handler_cls())
|
||||
|
||||
LOG.info(_LI('Starting server in PID %s') % os.getpid())
|
||||
LOG.debug("Configuration:")
|
||||
|
Loading…
Reference in New Issue
Block a user