Re: [hybi] An alternative design for the web socket handshake

Jamie Lokier <jamie@shareable.org> Mon, 17 May 2010 18:28 UTC

Return-Path: <jamie@shareable.org>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 0B0E83A6A80 for <hybi@core3.amsl.com>; Mon, 17 May 2010 11:28:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.066
X-Spam-Level:
X-Spam-Status: No, score=-1.066 tagged_above=-999 required=5 tests=[AWL=-1.067, BAYES_50=0.001]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GXu2nJT7unar for <hybi@core3.amsl.com>; Mon, 17 May 2010 11:28:32 -0700 (PDT)
Received: from mail2.shareable.org (mail2.shareable.org [80.68.89.115]) by core3.amsl.com (Postfix) with ESMTP id B1D813A6909 for <hybi@ietf.org>; Mon, 17 May 2010 11:28:32 -0700 (PDT)
Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from <jamie@shareable.org>) id 1OE534-0007Ou-FP; Mon, 17 May 2010 19:28:18 +0100
Date: Mon, 17 May 2010 19:28:18 +0100
From: Jamie Lokier <jamie@shareable.org>
To: Roberto Peon <fenix@google.com>
Message-ID: <20100517182818.GC20356@shareable.org>
References: <E6E437C7-BE01-4C27-A3E6-5B05A80599A6@apple.com> <20100514034909.GA23444@shareable.org> <4BECF665.5020102@webtide.com> <69603590-B1F1-4F0F-AE04-8F1EDD742D50@apple.com> <4BED0902.2000305@webtide.com> <20100514153843.GA6408@shareable.org> <AANLkTilMSegZkK6O4y7glXk2H5gnUDhtMJwtRTmLmbvV@mail.gmail.com> <20100516193850.GC29814@shareable.org> <338042B0-0DFD-4998-A079-C6E5278B5220@apple.com> <AANLkTimG8SoEc0q59p7bLngYJ9JDv6QF6vGukaOJ9fUh@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <AANLkTimG8SoEc0q59p7bLngYJ9JDv6QF6vGukaOJ9fUh@mail.gmail.com>
User-Agent: Mutt/1.5.13 (2006-08-11)
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] An alternative design for the web socket handshake
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 17 May 2010 18:28:34 -0000

Roberto Peon wrote:
> 
>    On Sun, May 16, 2010 at 5:16 PM, Maciej Stachowiak <[1]mjs@apple.com>
>    wrote:
> 
>    On May 16, 2010, at 12:38 PM, Jamie Lokier wrote:
>    >
>    > WebSocket would be almost unique, as a TLS user, in seeming to use
>    > 10-50 connections per individual user by design (the current one,
>    > where browsers can't share connections between WebSocket objects).
>    > TLS itself isn't designed with that kind of usage in mind.
> 
>      People keep saying this, but do we have any evidence there would be
>      10-50 connections per user to the same server?

I did explain in an earlier mail where that figure comes from.  In my
estimate, it isn't 10-50 per server, but 10-50 per user among all
servers they are connected to.  But when upstream proxies near the
client get involved (and mobile operators in particular might wish to
do so deliberately), then they are all to the same proxy.

It's interesting that Roberto points out that figure applies even to a
single server, although I expect only the most high profile servers
would see that.

That adds up to a *lot* of keepalive traffic when you consider, say,
an organisation with 100 users behind a 24Mbit/s-down 2Mbit/s-up link.
(When working it out, remember to include packet headers...)

One of the traffic pattern differences from HTTP that we've largely
not talked about is this:

WebSockets remain active when the user has a page open but it is
inactive, in the background, or even as an iconified/minimised window.
>From what I've seen, most pages are kept in that state nearly all the
time.  That is, they're left open in a browser that isn't being used
most of the time.

There is little or no HTTP traffic, but any WebSocket connections will
be relatively active, because they need to continuously transmit
"idle" keepalives, even if there are no data messages.  That's so they
will receive server-initiated messages when those happen.

In other words, there's a real chance that keepalives will be a large
fraction of traffic, or even dominant in some applications.  Moreover,
they are steady, so the traffic from multiple users doesn't
statistically multiplex as nicely as their bursty HTTP access.

I have seen that pattern in some non-web applications using a
publish-subscribe update model, which is one of the use-cases for
WebSocket in web pages.

>    Yes, and that is *without* the hanging gets.
>    Just try out the Alexa top XXX, and see for yourself!

That's useful, thank you.

(Btw, Imho we could really do with collecting the most useful
pointers, stats and so on together, out of the the many discussion
emails.  Anyone volunteer to help?)

>      For web apps using the "hanging get" approach, do you get 10-50
>      connections per user? If not, why would you expect it for
>      WebSocket? None of the typical "hanging get" techniques have a
>      built-in way to do connection sharing. Why do we expect things to
>      be different with WebSocket?
> 
>    It seems that more and more sites are using collaborative
>    and/or/notification-based features.

It's the notification-based features - or more generally,
server-initiated client updates - which I'm thinking about when I think
of WebSocket usage.

>    It seems natural that the number of requested concurrent streams
>    will increase as a result. The assumption that # concurrent
>    streams == # TCP connections does assume that we don't build in
>    multiplexing (or don't leave ourselves the possibility open for
>    the future). With multiplexing, the number of connections can go
>    down to the number of hosts involved. I sure hope for the sake of
>    the poor bottleneck (aka servers) that we do multiplexing right.

If there was more of a consensus in the direction of doing
multiplexing, or of an extension subprotocol that multiplexes, I'd be
happy to help make sure it is done well.  At the moment, the balance
of views expressed seems to be against multiplexing, and in favour of
one TCP connection per WebSocket object, but only just.

Within a single page, WebSocket browser apps can multiplex now - but
with faults.

It is done at the application layer by an app needing to dispatch
messages to different parts of the page.  The main issues I see in
multiplexing at the browser Javascript level, at present, are:

  - Separate open tabs/windows will have no choice but to use separate
    WebSockets.

  - Parts of a page authored using different frameworks, will
    inevitably use their own WebSocket objects.  (This is where the
    prediction that active ads will tend to add their own per-page
    WebSockets comes from.)

  - Without per-"channel" flow control (without considerable effort),
    if one independent part of the page, such as an iframe or WebWorker
    or whatever is unable to keep up with incoming updates, either the
    rest of the page stops receiving updates (a kind of head of line
    blocking), or the browser must use ever-increasing memory,
    queueing events faster than they are processed, to allow messages
    for the rest of the page to get through.

-- Jamie