From 3c7c355120a3ebe5c3f47e62176cec8cab824143 Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Mon, 25 Nov 2013 13:30:41 -0500 Subject: [PATCH] Use TCP_NODELAY for created sockets. Mark Seger at HP has been looking at small objects, 1 and 2 KB size, and with Rick Jones' help noticed that TCP protocol traces showed effects from the Nagel algorithm client-to-server and server-to-client. This patch just addresses our WSGI server responses, but does not address out-bound connections from the various servers. Change-Id: I11f86df1f56fba1c6ab6084dc1f580c395f072dc Signed-off-by: Peter Portante --- swift/common/wsgi.py | 1 + test/unit/common/test_wsgi.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/swift/common/wsgi.py b/swift/common/wsgi.py index 193322f2fa..f75e1f7a12 100644 --- a/swift/common/wsgi.py +++ b/swift/common/wsgi.py @@ -169,6 +169,7 @@ def get_socket(conf, default_port=8080): sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # in my experience, sockets can hang around forever without keepalive sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) + sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) if hasattr(socket, 'TCP_KEEPIDLE'): sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 600) if warn_ssl: diff --git a/test/unit/common/test_wsgi.py b/test/unit/common/test_wsgi.py index 085364c267..869fbe2593 100644 --- a/test/unit/common/test_wsgi.py +++ b/test/unit/common/test_wsgi.py @@ -246,11 +246,13 @@ class TestWSGI(unittest.TestCase): socket.SO_REUSEADDR: 1, socket.SO_KEEPALIVE: 1, }, + socket.IPPROTO_TCP: { + socket.TCP_NODELAY: 1, + } } if hasattr(socket, 'TCP_KEEPIDLE'): - expected_socket_opts[socket.IPPROTO_TCP] = { - socket.TCP_KEEPIDLE: 600, - } + expected_socket_opts[socket.IPPROTO_TCP][ + socket.TCP_KEEPIDLE] = 600 self.assertEquals(sock.opts, expected_socket_opts) # test ssl sock = wsgi.get_socket(ssl_conf)