[RFD] keepalive_timeout default: 2s => 5s

Eric Wong normalperson at yhbt.net
Fri Feb 19 17:09:04 EST 2010


This is mostly only relevant to folks who run Rainbows! without a proxy
in front of it, which I suppose are few...

The current keepalive time is only 2s, which is enough for broadband
connections and even tiny HTTP responses on dialup, but not enough
for large responses to slow clients.

For HTTP keepalive, there needs to be enough time to load all inline
assets (images/frames/iframes/JS/CSS/AJAX) without an additional TCP
connection.

For larger responses on slow connections (say 4K/s), this means the last
chunk of the response is written into the kernel socket buffer and the
userspace process (Rainbows!) has no visibility into when the client
finishes receiving data.

With Linux 2.6 defaults (16K TCP send buffer) with 4K/s downstream to
the client, that's 4 seconds of transfer time a userspace process
(Rainbows!) can't account for at all.

With the 2s default keepalive, Rainbows! would've timed out the client
connection before the client has even had a chance to finish receiving
data.

So with a 5s keepalive, we still leave the client with 1 second to fully
parse the initial HTML page and send more requests upstream.  Some
clients (afaik) parse HTML and send additional requests while
downloading.

Using 6 seconds would give some more room to deal with latency and slow
clients for little additional cost.

For reference, Apache 2.2 uses 5 seconds as the default, too.

  http://httpd.apache.org/docs/2.2/mod/core.html#keepalivetimeout

Given that several of Rainbows! concurrency models are less overhead
per-connection than Apache threaded/prefork models, 5-6 seconds should
be a safe enough default for us.

-- 
Eric Wong


More information about the rainbows-talk mailing list