From:  Patrick McManus <mcmanus@ducksong.com>
Date:  03 Feb 2015 23:26:28 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.tech.network
Subject:  

Re: Advice about TCP Keep-Alive settings for raw TCP Socket API?

NNTP-Posting-Host:  63.245.216.66

cc: steve who did the firefox work around this.

one of the issues you will run into is OS portability - you might very well
standardize something that's isn't portably implementable on standard
kernels.

Using sessions on the order of 2 or 3 minutes with a tiny bit of keep-alive
seems to work pretty well, and closing them after that point. That's the
HTTP/2 strategy right now. We've looked at the distribution of timeouts in
the past - there is a notable spike around 60 seconds, but it still only
made up a small fraction of the total distribution.

If you have some kind of nop like application layer method (such as smtp
nop :)) you can pipeline that just before your real operation and put a
timer on that response, creating a new session if it fails. This doesn't
add any latency due to the pipeline when everything is fine. That's a bit
better than open ended K-A in my opinion, particularly if you really hold
that connection open for a long duration. but some protocols (HTTP/1 e.g.)
aren't well suited to that.

There are of course severe tradeoffs in terms of battery and network
overhead in using tcp keep-alives. Most KA transmissions are going to be
full radio wakeups. I would think that those trades would be especially
painful for Firefox OS. Legacy protocols using that api might be better off
just taking the performance hit of establishing new connections.


On Tue, Feb 3, 2015 at 9:15 AM, Andrew Sutherland 
wrote:

> I raised an issue on the TCP and UDP socket web API spec (
> http://www.w3.org/2012/sysapps/tcp-udp-sockets/) about exposing TCP
> keep-alive settings at
> https://github.com/sysapps/tcp-udp-sockets/issues/80.  I did this because
> for the Firefox OS Gaia email app we were seeing connections that were
> effectively dead but without reasonable TCP keepalive settings we weren't
> noticing this (and then were at the mercy of the TCP retransmit timeouts,
> presumably.)
>
> Especially since we worked around the problem in the email app thus far by
> more aggressively closing otherwise-idle connections, I do not feel like I
> have sufficient wisdom/experience to confidently suggest the right course
> of defaults or whether it's best to expose the raw linux TCP stack settings
> or something else.
>
> So, if those on this list have opinions, especially those backed up by
> data, it would be great if you could chime in on
> https://github.com/sysapps/tcp-udp-sockets/issues/80.  It's probably
> worth noting that from the perspective of Firefox OS, the TCP socket API is
> a legacy API that exists to support existing pre-web technologies, but that
> web sockets and its origin-based security model are the way forward (or Web
> RTC's peer-to-peer mechanisms, etc.).  So the API doesn't have to be
> perfect.
>
> Andrew
> _______________________________________________
> dev-tech-network mailing list
> dev-tech-network@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-network
>
>