-
Notifications
You must be signed in to change notification settings - Fork 435
Add setting for max number of concurrent streams for HTTP/2 connection #1226
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
Conversation
|
|
…n to circumvent the limitation of a maximum of 100 concurrent calls as imposed by the default settings of NIOHTTP2Handler
glbrntt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this broadly looks good! I left a few notes inline but I think we'll also want a test for this. It could do something like:
- start a server setting max concurrent streams to N (where N > 100)
- connect to the server
- start N client streaming (or bidirectional streaming) RPCs
- send a message on each RPC (but do not send end)
- send end on RPC N
- wait for the status on RPC N (i.e. if this RPC does not complete then we didn't apply the setting correctly)
- send on all other RPCs, wait for them to complete
Sources/GRPC/ServerBuilder.swift
Outdated
| @discardableResult | ||
| public func with(httpMaxConcurrentStreams: Int) -> Self { | ||
| self.configuration.httpMaxConcurrentStreams = httpMaxConcurrentStreams | ||
| return self | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be moved down the file next to withHTTPTargetWindowSize(_:) and be named in a similar way?
Sources/GRPC/Server.swift
Outdated
| connectionIdleTimeout: TimeAmount = .nanoseconds(.max), | ||
| messageEncoding: ServerMessageEncoding = .disabled, | ||
| httpTargetWindowSize: Int = 65535, | ||
| httpMaxConcurrentStreams: Int = 100, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't add this here since it breaks public API -- moreover this init is deprecated anyway (It was deprecated such that we no longer have to deprecate and add new inits every time we add a new property to the configuration).
Sources/GRPC/Server.swift
Outdated
| public var httpTargetWindowSize: Int = 65535 | ||
|
|
||
| /// The HTTP/2 max number of concurrent streams. Defaults to 100. | ||
| public var httpMaxConcurrentStreams: Int = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a precondition in willSet that the new value must be >= 0? (And document the requirement)
Sources/GRPC/ClientConnection.swift
Outdated
| /// The HTTP/2 flow control target window size. Defaults to 65535. | ||
| public var httpTargetWindowSize = 65535 | ||
|
|
||
| public var httpMaxConcurrentStreams: Int = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't need this setting on the client configuration: the setting indicates to the other side how many streams they may create concurrently. I.e. here we're configuring how man the streams the server may create but for gRPC all streams are created by the client.
…r maxConcurrentStreams; Refactor
|
@glbrntt awesome, thanks for your comments, let me know what you think about my changes |
glbrntt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! We're just missing a bit of resource cleanup in the tests then this should be good to go.
glbrntt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you @qusc! 🙏
... in order to circumvent the limitation of a maximum of 100 concurrent calls as imposed by the default settings of NIOHTTP2Handler.