Re: [hybi] Technical feedback. was: Process!

Maciej Stachowiak <mjs@apple.com> Sat, 30 January 2010 08:15 UTC

Return-Path: <mjs@apple.com>
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 90BC23A6407 for <hybi@core3.amsl.com>; Sat, 30 Jan 2010 00:15:42 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -106.02
X-Spam-Level:
X-Spam-Status: No, score=-106.02 tagged_above=-999 required=5 tests=[AWL=-0.021, BAYES_00=-2.599, J_CHICKENPOX_26=0.6, RCVD_IN_DNSWL_MED=-4, USER_IN_WHITELIST=-100]
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 yUDle2oqwZ89 for <hybi@core3.amsl.com>; Sat, 30 Jan 2010 00:15:41 -0800 (PST)
Received: from mail-out3.apple.com (mail-out3.apple.com [17.254.13.22]) by core3.amsl.com (Postfix) with ESMTP id 5723C3A6358 for <hybi@ietf.org>; Sat, 30 Jan 2010 00:15:41 -0800 (PST)
Received: from relay16.apple.com (relay16.apple.com [17.128.113.55]) by mail-out3.apple.com (Postfix) with ESMTP id AFE5C82B50F0 for <hybi@ietf.org>; Sat, 30 Jan 2010 00:16:06 -0800 (PST)
X-AuditID: 11807137-b7bd4ae000000f0d-c0-4b63eac6c88e
Received: from elliott.apple.com (elliott.apple.com [17.151.62.13]) by relay16.apple.com (Apple SCV relay) with SMTP id A0.78.03853.6CAE36B4; Sat, 30 Jan 2010 00:16:06 -0800 (PST)
MIME-version: 1.0
Content-type: text/plain; charset="us-ascii"
Received: from [17.151.93.115] by elliott.apple.com (Sun Java(tm) System Messaging Server 6.3-7.04 (built Sep 26 2008; 32bit)) with ESMTPSA id <0KX1001MYWAUW950@elliott.apple.com> for hybi@ietf.org; Sat, 30 Jan 2010 00:16:06 -0800 (PST)
From: Maciej Stachowiak <mjs@apple.com>
In-reply-to: <4B63DC2D.4090702@webtide.com>
Date: Sat, 30 Jan 2010 00:16:05 -0800
Content-transfer-encoding: quoted-printable
Message-id: <4678E38C-EBD3-4867-B3A6-53A60F7F26C0@apple.com>
References: <de17d48e1001280012i2657b587i83cda30f50013e6b@mail.gmail.com> <4B620B8F.6030706@gmx.de> <Pine.LNX.4.64.1001282217320.22053@ps20323.dreamhostps.com> <bbeaa26f1001281449q1a6e1813q3f537fe15a5a9d60@mail.gmail.com> <4B625733.2020907@webtide.com> <6.2.5.6.2.20100128225542.06fa8d68@resistor.net> <Pine.LNX.4.64.1001290817520.22020@ps20323.dreamhostps.com> <4B62C5FE.8090904@it.aoyama.ac.jp> <Pine.LNX.4.64.1001291134350.22020@ps20323.dreamhostps.com> <4B62E516.2010003@webtide.com> <5c902b9e1001290756r3f585204h32cacd6e64fbebaa@mail.gmail.com> <4B636757.3040307@webtide.com> <BBF3CE06-3276-4A7C-8961-7B3DDEE406D0@apple.com> <4B63DC2D.4090702@webtide.com>
To: Greg Wilkins <gregw@webtide.com>
X-Mailer: Apple Mail (2.1077)
X-Brightmail-Tracker: AAAAAQAAAZE=
Cc: Hybi <hybi@ietf.org>
Subject: Re: [hybi] Technical feedback. was: Process!
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: Sat, 30 Jan 2010 08:15:42 -0000

On Jan 29, 2010, at 11:13 PM, Greg Wilkins wrote:

> 
>>> So if you look on the wire of cometd running over websocket,
>>> it just looks like long polling.  We use the same /meta/connect
>>> long poll message as a keep alive and as our ack carrier.
>>> 
>>> We've saved 1 connection, which is great.   But I fear that
>>> saving will be eaten up by the ability of application developers
>>> to open any number of websockets.
>> 
>> Doesn't it also save you the need to potentially close and reopen the connection that would have been used for messages from the client to the server? It seems like proper full duplex is a significant win, especially over SSL where connection setup is very expensive.
> 
> No.  HTTP/1.1 keeps the connection open between long poll
> requests.

HTTP/1.1 doesn't guarantee that the client will actually reuse the connection, it just makes it possible.

> 
> For a few use-cases that are streaming large volumes of data that
> is almost continuous will get greater throughput.
> 
> But for many many comet applications (eg chat, auctions,
> monitoring), the events a far enough a part and small enough
> that in most cases there is a waiting long poll and the
> response fits in a single MTU.   For these use cases,
> websockets only helps with the minority of events that
> occur when there is not a long poll waiting, thus it
> really only helps the maximal latency.

Sure, throughput is not much concern when your average bandwidth is low compared to your network capacity.

> 
> 
>>> But as I've frequently said, it works ok, but it solves
>>> few of my real pain points as comet vendor and it's
>>> caused me more code/complexity not less.
>> 
>> I'm curious to hear about some of the pain points that you think are not addressed. You mentioned two (reliable message delivery and maintaining idle connections) and I think you're right that those should be addressed. Any others?
> 
> For the scaling of the web applications that I work with,
> connections have often been the limiting factor.
> 
> Websockets have no limits on the number of connections
> that an application can open, thus no limit on the
> amount of server side resources that a client side
> developer can requisition.

It does have a limit that the client can only be starting one connection per server at a time (see section 4.1, step 1 in the algorithm), and allows servers to reject connections. Thus the server could enforce a connection limit per client IP or per client IP+Origin. It seems like that is enough to limit the potential for abuse. What do you think?

> 
> I've previously explained in detail how a widget vendor
> might find some better performance by opening multiple
> websockets, so that they get a greater share of the
> bandwidth available from a server.   But that only
> works if your the only one doing it.  Soon everybody
> will be opening 4, 8, 16 connections etc.

So, this seems to have an assumption that the client-side code is developed by an independent entity from the server-side code. I can see how that might be true if your WebSocket service is intended for cross-site use. However, it seems like that often won't be the case. For example, a vendor providing the chat service is likely to author both the client-side JavaScript and the server-side code to manage it. Presumably they would not make this mistake. We do need to make sure that it's practical for clients to minimize the number of connections they choose to use of course.

For the cross-origin case, enforcing a connection limit (rather than just making multiplexing possible) seems challenging. You would have to multiplex messages to and from all clients over a single connection, which means content destined for different security domains is being sent over one pipe. While that's not a security issue per se, it does increase the risk of problems. It also may creates a challenge for multiprocess browsers. It could also cause problems when multiple independent services are hosted on a single origin, where one sends many small messages that need low latency, and another may send occasional messages that are very large. The large messages would put spikes in your latency that you can't avoid. (One way to deal might be to redesign the protocol to split large messages.) I would like to clearly understand the cost/benefit tradeoff before we consider making a single connection (or some other small number) mandatory.

It also seems that in the case of many likely services, using multiple connections gives no obvious benefit. For example, if I'm connecting to a chat server, will it really help me to have 4 connections instead of 1? I don't see how. Even for something more bandwidth-intensive like video streaming, how will multiple connections help? It seems like it could only possibly be of benefit if the protocol you are using over WebSocket lets you split data relating to the same operations over multiple connections. But it seems like that is in the server developer's hands. The reason HTTP clients sometimes violate the connection limit is because the nature of the protocol *does* give a benefit when opening many connections - you can evade bandwidth limits on large downloads using range requests, or make sure that you get low latency for critical resources without head-of-line blocking when making many requests. But I don't think that translates to many foreseeable kinds of WebSocket services, where having a single stateful stream is essential to using a service.

I do think the ability to do multiplexing as an optional feature may be useful. I see it as something that could be a 2.0 (or 1.1) protocol feature, and that could be totally transparent in the client API. But if there are pitfalls that make it impossible to roll out later, it would be good to know now.

> working with load balancers and other intermediaries
> that need out-of-band communication with the server
> is another.

What's needed for the sake of these kinds of intermediaries? I think the principle we should apply here is that the protocol should be able to work with no changes to intermediaries in general, but if we have a way to make it work better with optional cooperation from intermediaries, we should consider it. Can you mention some concrete problems that come up here? Do you have solutions in mind?

> 
>>> It's not provided any semantics that would allow
>>> any cometd users to consider going directly to websockets
>>> instead of using a comet framework.   Sure it makes sending
>>> messages easy, but that is always easy. It does not help
>>> for when you can't send messages or when connections drop
>>> or servers change etc.   These are all the realworld things
>>> that must be dealt with and ws makes this harder not easier.
>> 
>> What kind of changes do you think would make it more practical to use WebSocket directly rather than go through a framework?
> 
> I actually fear the opposite.
> 
> It's like every book on Ajax starts with a chapter about how to
> program directly to XHR.  So app developers go off and program
> directly to XHR and get them selves in all sorts of strife.
> Any seasoned Ajax developer will always tell you to have some
> kind of framework wrapping XHR.
> 
> The same is going to happen with websockets.  Programmers
> are going to seee books/publicity about it and start using
> it directly.   Websocket is really easy to use and they will
> soon have working bidirectional applications.
> 
> But working bidirectional applications are easy even with
> simple HTTP.    The hard thing is how to make an applications
> that fail well, or handle a laggy intermittent mobile network,
> or can cope with strange intermediaries etc.   Websocket
> provides a solution for very few of the problems that you
> get doing bidirectionality over HTTP.   So programmers are
> just going to go out and make a whole bunch of crappy
> applications that don't work well in the real world
> and we'll be picking up the pieces for years to come.

What I'm really interested in here is the problems themselves, not what form the damage will take. You did list some. That's great. It would be good to list any others, and to work on solutions to the ones identified.

Regards,
Maciej