Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open new HTTP/2 connections when stream space is exhausted. #283

Closed
tomchristie opened this issue Aug 27, 2019 · 7 comments
Closed

Open new HTTP/2 connections when stream space is exhausted. #283

tomchristie opened this issue Aug 27, 2019 · 7 comments
Assignees
Labels
bug Something isn't working http/2 Issues and PRs related to HTTP/2

Comments

@tomchristie
Copy link
Member

http://http2.github.io/http2-spec/index.html#StreamIdentifiers "Long-lived connections can result in an endpoint exhausting the available range of stream identifiers. A client that is unable to establish a new stream identifier can establish a new connection for new streams. "

Somewhat related to #282

@sethmlarson sethmlarson added good first issue Good for newcomers http/2 Issues and PRs related to HTTP/2 labels Aug 27, 2019
@gdhameeja
Copy link
Contributor

I would like to work on this.

gdhameeja added a commit to gdhameeja/httpx that referenced this issue Sep 10, 2019
Opens new http2 connections when no more stream IDs are available
Handle this by catching the exception `NoAvailableStreamIDError` thrown by h2-hyper.
@florimondmanca
Copy link
Member

Is this actually an issue for us?

h2 sets its HIGHEST_ALLOWED_STREAM_ID to 2^31 - 1, which is ~2^30 streams we can open (client-side stream IDs are always odd), i.e. about 1M streams. Are we ever going to open that many connections, and still want to open more after that point? Surely the MAX_CONCURRENT_STREAMS limit imposed by h2 (100 by default) will hit us before that.

@sethmlarson
Copy link
Contributor

Stream space is number of requests on a single connection, since each request requires its own stream. The concurrent streams limit is the number of requests you're allowed to have outstanding before making a new request.

@florimondmanca
Copy link
Member

florimondmanca commented Sep 21, 2019

OK, I think we've got a shared understanding then.

What made me think about whether this is a practical issue is this:

https://github.com/python-hyper/hyper-h2/blob/385ced7d30a7ccb9b3f163f1bc4e90cf2f4ee184/h2/connection.py#L641-L651

Essentially, we can only get a NoAvailableStreamIDError when the HIGHEST_ALLOWED_STREAM_ID is reached, which is when we're making 1 million requests to the same host via a single connection. How likely is that to happen? Or maybe I'm completely missing something?

@sethmlarson
Copy link
Contributor

It's not likely in everyday usage but it's a part of being a consumer of the h2 library. I can see it eventually happening for servers with connections to external APIs.

@sethmlarson sethmlarson removed the good first issue Good for newcomers label Sep 30, 2019
@tomchristie tomchristie added the bug Something isn't working label Dec 23, 2019
@ojii
Copy link

ojii commented Feb 18, 2020

Essentially, we can only get a NoAvailableStreamIDError when the HIGHEST_ALLOWED_STREAM_ID is reached, which is when we're making 1 million requests to the same host via a single connection. How likely is that to happen? Or maybe I'm completely missing something?

We do about 1 million requests per day to a single host (APNS) in our application, so to me it doesn't seem too unrealistic to hit this limit, if a connection stays open for some time.

@tomchristie
Copy link
Member Author

Believe this to now be resolved in the 0.13.dev0 pre-release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working http/2 Issues and PRs related to HTTP/2
Projects
None yet
5 participants