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

Limit usage of HTTP/2 connections #5888

Closed
sbordet opened this issue Jan 17, 2021 · 7 comments · Fixed by #12401
Closed

Limit usage of HTTP/2 connections #5888

sbordet opened this issue Jan 17, 2021 · 7 comments · Fixed by #12401
Assignees
Labels
Specification For all industry Specifications (IETF / Servlet / etc)

Comments

@sbordet
Copy link
Contributor

sbordet commented Jan 17, 2021

Jetty version
9.4.x

Description
HTTP/2 connections have an implicit max usage count determined by the fact that stream ids can go up to 2^31-1 and cannot be negative.

As such, the HTTP/2 client connection pool should default to close connections as they reach that limit (or maybe just before that).

@lorban
Copy link
Contributor

lorban commented Jan 20, 2021

@sbordet I've submitted a draft PR that enforces such limitation in HttpClientTransportOverHTTP2. Did you have something more sophisticated in mind?

@sbordet
Copy link
Contributor Author

sbordet commented Jan 20, 2021

@lorban streams are incremented by 2, so it should be something like (2^31-1)/2 as the max usage count.
And we have to make sure that we don't accidentally go off-by-one (i.e. use the stream one more time that would produce a stream id of 2^31).

2^31-1 = 2147483647

On the client, stream usage N produces stream id N*2-1, so we should be safe with N=1073741823.
However, we need to take into account HTTP upgrades which have an implicit stream id of 1 -- not sure how that is counted.

On the server, stream usage N produces stream id N*2, so we should be safe with N=1073741823.

I would probably be on the safe side and stay at N=1073741822 or perhaps even less.

On the client, it's easy to set this value on the Pool.

On the server, though, there is no Pool so we need to explore some other mechanism to enforce this.

There are 2 choices for the server:
. stop pushing without closing the connection.
. gracefully close the connection so the client is forced to open a new one.

I'd go with the simpler, which I feel is stop pushing -- after all it's unlikely that the server pushes 1 billion resources to the client through the same connection (although it's possible).

We need test cases for the server case (I think the client case is already covered in the Pool tests).

@github-actions
Copy link

This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the Stale For auto-closed stale issues and pull requests label Jan 21, 2022
@sbordet sbordet removed the Stale For auto-closed stale issues and pull requests label Jan 21, 2022
@sbordet
Copy link
Contributor Author

sbordet commented Jan 21, 2022

@lorban status of this issue?

@lorban
Copy link
Contributor

lorban commented Jan 24, 2022

@sbordet enforcing (and testing) this on the server is far from trivial so the balance between the benefits vs the required effort has been negative so far.

@sbordet
Copy link
Contributor Author

sbordet commented Jan 24, 2022

@lorban I don't think it's that difficult. Can you detail?
BTW, don't we do this already for HTTP/3 as well?

@github-actions
Copy link

This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions bot added the Stale For auto-closed stale issues and pull requests label Jan 25, 2023
@sbordet sbordet removed the Stale For auto-closed stale issues and pull requests label Jan 26, 2023
@joakime joakime added Pinned Issues that never go stale Specification For all industry Specifications (IETF / Servlet / etc) and removed Pinned Issues that never go stale labels Jan 24, 2024
@joakime joakime removed this from Jetty 12.0.14 Sep 25, 2024
@sbordet sbordet assigned sbordet and unassigned lorban Oct 17, 2024
@sbordet sbordet moved this to 🏗 In progress in Jetty 12.0.15 FROZEN Oct 17, 2024
sbordet added a commit that referenced this issue Oct 17, 2024
* Made the high-level HttpConnectionOverHTTP2 implement MaxUsable, so it cannot be used to open more streams than allowed.
* Implemented low-level handling of explicit stream ids provided by applications.
* Implemented low-level handling of stream id overflow.
* Added test cases.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet linked a pull request Oct 17, 2024 that will close this issue
lorban added a commit that referenced this issue Oct 23, 2024
sbordet added a commit that referenced this issue Oct 27, 2024
* Now using a placeholder HTTP2Stream for streams opened with a PRIORITY, but not yet with a HEADERS.

Signed-off-by: Simone Bordet <[email protected]>
sbordet added a commit that referenced this issue Oct 28, 2024
* Fixed maxUsage check in AbstractConnectionPool.

Signed-off-by: Simone Bordet <[email protected]>
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.15 FROZEN Oct 31, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.15 FROZEN Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Specification For all industry Specifications (IETF / Servlet / etc)
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants