Re: Design Issue: Max Concurrent Streams Limit and Unidirectional Streams

Martin Thomson <martin.thomson@gmail.com> Thu, 25 April 2013 19:26 UTC

Return-Path: <ietf-http-wg-request@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 3F5B321F96BA for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Thu, 25 Apr 2013 12:26:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -10.599
X-Spam-Level:
X-Spam-Status: No, score=-10.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ySxrKrHXs2E3 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Thu, 25 Apr 2013 12:26:33 -0700 (PDT)
Received: from frink.w3.org (frink.w3.org [128.30.52.56]) by ietfa.amsl.com (Postfix) with ESMTP id 7917921F9659 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Thu, 25 Apr 2013 12:26:33 -0700 (PDT)
Received: from lists by frink.w3.org with local (Exim 4.72) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1UVRo4-0002eq-8Z for ietf-http-wg-dist@listhub.w3.org; Thu, 25 Apr 2013 19:26:12 +0000
Resent-Date: Thu, 25 Apr 2013 19:26:12 +0000
Resent-Message-Id: <E1UVRo4-0002eq-8Z@frink.w3.org>
Received: from maggie.w3.org ([128.30.52.39]) by frink.w3.org with esmtp (Exim 4.72) (envelope-from <martin.thomson@gmail.com>) id 1UVRnz-0002eA-Kg for ietf-http-wg@listhub.w3.org; Thu, 25 Apr 2013 19:26:07 +0000
Received: from mail-we0-f181.google.com ([74.125.82.181]) by maggie.w3.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from <martin.thomson@gmail.com>) id 1UVRnv-0007TD-2a for ietf-http-wg@w3.org; Thu, 25 Apr 2013 19:26:07 +0000
Received: by mail-we0-f181.google.com with SMTP id m1so2918496wea.40 for <ietf-http-wg@w3.org>; Thu, 25 Apr 2013 12:25:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=vJ10L6rg2S3BdYtk5kmeKr7YLAhmvb0Pm9gyZ2pBxoU=; b=KVfMW2lJwXLorBwQMeNwcyAoJsqTqilYZP5gjksqjGWQ45iLDT7Aldp9GrQYYoa7OJ uS3SRy2N7wwJX0pnOIEM48li3iHPsV2JTzrqqxYh7swJaUkXOvc7YvW9+83J2/ABq9cD 4j29zS9tAKUjfvSwjLQeBpa8V8/vfKkLfXZVbvvEnEh/5HXuSDOeOMg6PrVeEPOxXAJ2 62neGqjdanBSAB/jlbJaqfgNDfxr0U1MlskEv7w4qnR7aaUBf4SB29DP/QaQ8Qkdyjha RiemnxT2AWi9dPZtDYEJXiqKp12o4aAgUcFK425185DmeT3FKi9NeAI8QmUOpItbHWwZ jBrA==
MIME-Version: 1.0
X-Received: by 10.194.235.196 with SMTP id uo4mr5902612wjc.30.1366917936924; Thu, 25 Apr 2013 12:25:36 -0700 (PDT)
Received: by 10.194.33.102 with HTTP; Thu, 25 Apr 2013 12:25:36 -0700 (PDT)
In-Reply-To: <CABP7RbdBe-Xkx+CMvpN=_oNAqm6SyLyL+XNHRUKSqn8mjSDw1Q@mail.gmail.com>
References: <CABP7RbdBe-Xkx+CMvpN=_oNAqm6SyLyL+XNHRUKSqn8mjSDw1Q@mail.gmail.com>
Date: Thu, 25 Apr 2013 12:25:36 -0700
Message-ID: <CABkgnnW=Ve=9p2do5PncTVswTYCZqt-LMK50SYCKV1r8zEg=SQ@mail.gmail.com>
From: Martin Thomson <martin.thomson@gmail.com>
To: James M Snell <jasnell@gmail.com>
Cc: "ietf-http-wg@w3.org" <ietf-http-wg@w3.org>
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=74.125.82.181; envelope-from=martin.thomson@gmail.com; helo=mail-we0-f181.google.com
X-W3C-Hub-Spam-Status: No, score=-4.4
X-W3C-Hub-Spam-Report: AWL=-1.730, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001
X-W3C-Scan-Sig: maggie.w3.org 1UVRnv-0007TD-2a 29321d9ab3bdea8dfc70c7e147a2d3cf
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Design Issue: Max Concurrent Streams Limit and Unidirectional Streams
Archived-At: <http://www.w3.org/mid/CABkgnnW=Ve=9p2do5PncTVswTYCZqt-LMK50SYCKV1r8zEg=SQ@mail.gmail.com>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/17573
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <http://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On 25 April 2013 10:50, James M Snell <jasnell@gmail.com> wrote:
> https://github.com/http2/http2-spec/issues/78
>...
> If a client sets a limit of 4 concurrent streams, and the server
> initiates 4 separate PUSH_PROMISE streams that the server half-closes
> but that are never half-closed by the client, the server will not be
> able to initiate new push streams for the duration of the session.

Yep, it's a problem.  We got rid of the unidirectional flag that
addressed this.  I can't speak for others, but I was aware of the
issue at the time, but I had a solution in mind.  That never got
written down, partly because we didn't have this discussion :)

On first blush, the only way to avoid the problem is to expect the
framing layer to be aware of what is going on above, but that's
probably not sensible.  But there's a better way:

Each stream has two separate state variables, each with three state
values: no packet yet, open, half-closed.  Streams that have inbound
== open || outbound == open are "in use" and count toward the stream
limit.  Documenting this might help clarify how the accounting is
done.

Importantly, this means that promised streams do not count toward the
limit.  It does however also imply that implementations will need to
be careful about how they allocate stream resources.  Pushes
complicate that a little because the lifecycle of headers doesn't
match stream lifecycles.  Again, I'd suggest an approach where
implementations defer commitment of flow control buffers until the
first flow-controlled frame arrives (memory pre-allocation might be
advisable for performance reasons, but that would not be an actual
commitment) and to ensure that any state for send and receive don't
have the same lifecycle.