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

http2: limit client initial MAX_CONCURRENT_STREAMS #73

Closed
wants to merge 1 commit into from

Conversation

stevenh
Copy link
Contributor

@stevenh stevenh commented Jun 4, 2020

Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting maxConcurrentStreams to 100, the http2 specifications
recommended minimum, until we've received the initial SETTINGS frame from the server.

After a SETTINGS frame has been received use the servers MAX_CONCURRENT_STREAMS, if present, otherwise use 1000 as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Fixes golang/go#39389

Prevent the client trying to establish more streams than the server is
willing to accept during the initial life time of a connection by
limiting maxConcurrentStreams to 100, the http2 specifications
recommended minimum, until we've received the initial SETTINGS frame
from the server.

After a SETTINGS frame has been received use the servers
MAX_CONCURRENT_STREAMS, if present, otherwise use 1000 as a reasonable
value.

For normal consumers this will have very little impact, allowing a
decent level of concurrency from the start, and for highly concurrent
consumers or large bursts it will prevent significant number of rejected
streams being attempted hence actually increasing performance.

Fixes golang/go#39389
@stevenh stevenh marked this pull request as ready for review June 4, 2020 09:55
@gopherbot
Copy link
Contributor

This PR (HEAD: 0d1114d) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/net/+/236497 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
maxFrameSize: 16 << 10, // spec default
initialWindowSize: 65535, // spec default
maxConcurrentStreams: initialMaxConcurrentStreams, // "infinite", per spec. Use a smaller value until we have received server settings.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any restrictions that preventing setting maxConcurrentStreams in Transport configurations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be done but it only has meaning for http2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it only has meaning for http2

What do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transport configurations come from: https://pkg.go.dev/net/http#Transport which is used for http1 and http2, just flagging that adding an option for initial max concurrent streams would be http2 specific.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using https://pkg.go.dev/net/http#Transport with function https://pkg.go.dev/golang.org/x/net/http2#ConfigureTransports limited the connection reuse cases:

net/http2/transport.go

Lines 173 to 176 in ad29c8a

t2 := &Transport{
ConnPool: noDialClientConnPool{connPool},
t1: t1,
}

This may result in an http2: no cached connection was available error from the lines below:

net/http2/transport.go

Lines 476 to 480 in ad29c8a

cc, err := t.connPool().GetClientConn(req, addr)
if err != nil {
t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err)
return nil, err
}

Aren't you modifying the http2 package source code? Why shouldn't it have a MaxConcurrentStreams specific configuration anyway?

@gopherbot
Copy link
Contributor

Message from Brad Fitzpatrick:

Patch Set 2: Code-Review+2


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Brad Fitzpatrick:

Patch Set 2: Trust+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Brad Fitzpatrick:

Patch Set 2: Run-TryBot+1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go Bot:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go Bot:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Go Bot:

Patch Set 2: TryBot-Result-1

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Joe Tsai:

Patch Set 2: Trust+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/236497.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Sep 7, 2021
Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting `maxConcurrentStreams` to `100`, the http2 specifications
recommended minimum, until we've received the initial `SETTINGS` frame from the server.

After a `SETTINGS` frame has been received use the servers `MAX_CONCURRENT_STREAMS`, if present, otherwise use `1000` as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Fixes golang/go#39389

Change-Id: I35fecd501ca39cd059c7afd1d44090b023f16e1e
GitHub-Last-Rev: 0d1114d
GitHub-Pull-Request: #73
Reviewed-on: https://go-review.googlesource.com/c/net/+/236497
Reviewed-by: Brad Fitzpatrick <[email protected]>
Trust: Brad Fitzpatrick <[email protected]>
Trust: Joe Tsai <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/236497 has been merged.

@gopherbot gopherbot closed this Sep 7, 2021
gopherbot pushed a commit that referenced this pull request Oct 29, 2021
…RRENT_STREAMS

Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting `maxConcurrentStreams` to `100`, the http2 specifications
recommended minimum, until we've received the initial `SETTINGS` frame from the server.

After a `SETTINGS` frame has been received use the servers `MAX_CONCURRENT_STREAMS`, if present, otherwise use `1000` as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Updates golang/go#49076

Change-Id: I35fecd501ca39cd059c7afd1d44090b023f16e1e
GitHub-Last-Rev: 0d1114d
GitHub-Pull-Request: #73
Reviewed-on: https://go-review.googlesource.com/c/net/+/236497
Reviewed-by: Brad Fitzpatrick <[email protected]>
Trust: Brad Fitzpatrick <[email protected]>
Trust: Joe Tsai <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
Reviewed-on: https://go-review.googlesource.com/c/net/+/356979
Trust: Damien Neil <[email protected]>
Run-TryBot: Damien Neil <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
gopherbot pushed a commit that referenced this pull request Oct 29, 2021
…RRENT_STREAMS

Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting `maxConcurrentStreams` to `100`, the http2 specifications
recommended minimum, until we've received the initial `SETTINGS` frame from the server.

After a `SETTINGS` frame has been received use the servers `MAX_CONCURRENT_STREAMS`, if present, otherwise use `1000` as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Updates golang/go#49077

Change-Id: I35fecd501ca39cd059c7afd1d44090b023f16e1e
GitHub-Last-Rev: 0d1114d
GitHub-Pull-Request: #73
Reviewed-on: https://go-review.googlesource.com/c/net/+/236497
Reviewed-by: Brad Fitzpatrick <[email protected]>
Trust: Brad Fitzpatrick <[email protected]>
Trust: Joe Tsai <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
Reviewed-on: https://go-review.googlesource.com/c/net/+/357674
Trust: Damien Neil <[email protected]>
Run-TryBot: Damien Neil <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
dteh pushed a commit to dteh/fhttp that referenced this pull request Jun 22, 2022
Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting `maxConcurrentStreams` to `100`, the http2 specifications
recommended minimum, until we've received the initial `SETTINGS` frame from the server.

After a `SETTINGS` frame has been received use the servers `MAX_CONCURRENT_STREAMS`, if present, otherwise use `1000` as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Fixes golang/go#39389

Change-Id: I35fecd501ca39cd059c7afd1d44090b023f16e1e
GitHub-Last-Rev: 0d1114d3a558cefed17008aba3e4a4d7b2ad3866
GitHub-Pull-Request: golang/net#73
Reviewed-on: https://go-review.googlesource.com/c/net/+/236497
Reviewed-by: Brad Fitzpatrick <[email protected]>
Trust: Brad Fitzpatrick <[email protected]>
Trust: Joe Tsai <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
fedosgad pushed a commit to fedosgad/oohttp that referenced this pull request Jun 22, 2022
…RRENT_STREAMS

Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting `maxConcurrentStreams` to `100`, the http2 specifications
recommended minimum, until we've received the initial `SETTINGS` frame from the server.

After a `SETTINGS` frame has been received use the servers `MAX_CONCURRENT_STREAMS`, if present, otherwise use `1000` as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Updates golang/go#49077

Change-Id: I35fecd501ca39cd059c7afd1d44090b023f16e1e
GitHub-Last-Rev: 0d1114d3a558cefed17008aba3e4a4d7b2ad3866
GitHub-Pull-Request: golang/net#73
Reviewed-on: https://go-review.googlesource.com/c/net/+/236497
Reviewed-by: Brad Fitzpatrick <[email protected]>
Trust: Brad Fitzpatrick <[email protected]>
Trust: Joe Tsai <[email protected]>
Run-TryBot: Brad Fitzpatrick <[email protected]>
Reviewed-on: https://go-review.googlesource.com/c/net/+/357674
Trust: Damien Neil <[email protected]>
Run-TryBot: Damien Neil <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x/net/http2: max connections overflow
4 participants