Skip to content

OkHttpServer: support maxConcurrentCallsPerConnection (Fixes #11062). #11063

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

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

hypnoce
Copy link
Contributor

@hypnoce hypnoce commented Mar 31, 2024

  • Add option in OkHttpServerBuilder
  • Add value as MAX_CONCURRENT_STREAM setting in settings frame sent by the server to the client per connection
  • Enforce limit by sending a RST frame with REFUSED_STREAM error

This PR is really a try since I may be not enough familiar with all gRPC internals. Let me know if I'm too far from a correct solution.

@hypnoce hypnoce force-pushed the max_concurrent_Streams_okhttp branch from a42b7bd to 553f169 Compare March 31, 2024 22:21
…).

* Add option in OkHttpServerBuilder
* Add value as MAX_CONCURRENT_STREAM setting in settings frame sent by the server to the client per connection
* Enforce limit by sending a RST frame with REFUSED_STREAM error
@hypnoce hypnoce force-pushed the max_concurrent_Streams_okhttp branch from 553f169 to bbd84b2 Compare March 31, 2024 22:31
@@ -638,6 +644,11 @@ public void headers(boolean outFinished,
newStream = streamId > lastStreamId;
if (newStream) {
lastStreamId = streamId;
if (config.maxConcurrentStreams <= streams.size()) {
streamError(streamId, ErrorCode.REFUSED_STREAM,
Copy link
Member

Choose a reason for hiding this comment

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

PROTOCOL_ERROR would handle implementation bugs better, because the streams wouldn't be retried. But there is a handshake race for new connections where the client may initially exceed the stream limit. REFUSED_STREAM is most helpful if the stream limit is changing over the life of the connection. To make this "really nice" we could set a flag in ackSettings() and do receivedSettingsAck ? ErrorCode.PROTOCOL_ERROR : ErrorCode.REFUSED_STREAM, because there's no valid reason for the client to exceed the stream limit after acking the settings.

But what you have is fine, and that'd be more annoying for you to test.

@ejona86 ejona86 requested a review from temawi April 1, 2024 14:36
@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Apr 1, 2024
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Apr 1, 2024
@temawi temawi merged commit 8050723 into grpc:master Apr 1, 2024
15 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants