mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
support TCP Fast Open option
Fast Open" is a optimization to the process of stablishing a TCP connection that allows the elimination of one round time trip (RTT) from certain kinds of TCP conversations. Fast Open could result in speed improvements of between 4% and 41% in the page load times on popular web sites. Available on linux >= 3.7.1. More info: - https://lwn.net/Articles/508865/ - http://research.google.com/pubs/pub37517.html
This commit is contained in:
parent
a1a4fd47ad
commit
fea9e76e7d
@ -1292,3 +1292,33 @@ class SyslogFacility(Setting):
|
|||||||
desc = """\
|
desc = """\
|
||||||
Syslog facility name
|
Syslog facility name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class AllowTCPFastOpen(Setting):
|
||||||
|
name = "allow_tcp_fast_open"
|
||||||
|
section = "Server Socket"
|
||||||
|
cli = ["--allow-tcp-fast-open"]
|
||||||
|
validator = validate_bool
|
||||||
|
default = False
|
||||||
|
action = "store_true"
|
||||||
|
desc = """\
|
||||||
|
Whether the server will allow the TCP Fast Open.
|
||||||
|
|
||||||
|
Available on Linux >= 3.7.1, Python>= 3.4
|
||||||
|
|
||||||
|
More info: http://research.google.com/pubs/pub37517.html
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class TCPFastOpenQueue(Setting):
|
||||||
|
name = "tcp_fast_open_queue"
|
||||||
|
section = "Server Socket"
|
||||||
|
cli = ["--tcp-fast-open-queue"]
|
||||||
|
meta = "INT"
|
||||||
|
validator = validate_pos_int
|
||||||
|
type = int
|
||||||
|
default = 5
|
||||||
|
desc = """\
|
||||||
|
The size of the TCP Fast Open queue. If the number of connections exceed
|
||||||
|
this value, the other connections are proceed with a normal 3-way.
|
||||||
|
"""
|
||||||
|
|||||||
@ -67,6 +67,11 @@ class TCPSocket(BaseSocket):
|
|||||||
|
|
||||||
def set_options(self, sock, bound=False):
|
def set_options(self, sock, bound=False):
|
||||||
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||||
|
|
||||||
|
if hasattr(socket, 'TCP_FASTOPEN') and self.cfg.allow_tcp_fast_open:
|
||||||
|
sock.setsockopt(socket.SOL_TCP, socket.TCP_FASTOPEN,
|
||||||
|
self.cfg.tcp_fast_open_queue)
|
||||||
|
|
||||||
return super(TCPSocket, self).set_options(sock, bound=bound)
|
return super(TCPSocket, self).set_options(sock, bound=bound)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user