From 76025a5b53836bb6271c130c78b0f10709e7a64a Mon Sep 17 00:00:00 2001 From: Siddharth Nohria Date: Mon, 12 May 2025 06:51:45 +0000 Subject: [PATCH 1/4] Proposal for max_outstanding_streams in ResourceQuota --- L122-max-outstanding-streams.md | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 L122-max-outstanding-streams.md diff --git a/L122-max-outstanding-streams.md b/L122-max-outstanding-streams.md new file mode 100644 index 000000000..5f5687e44 --- /dev/null +++ b/L122-max-outstanding-streams.md @@ -0,0 +1,43 @@ +Title +---- +* Author(s): Siddharth Nohria +* Approver: Craig Tiller +* Status: Draft +* Implemented in: C++ +* Last updated: 2025-05-12 +* Discussion at: (filled after thread exists) + +## Abstract + +Allow servers to set a server-wide `MAX_CONCURRENT_STREAMS` as part of the +Resource Quota, in addition to the current per-connection `MAX_CONCURRENT_STREAMS`. + +## Background + +HTTP2 protocol provides the `MAX_CONCURRENT_STREAMS` setting as a way to limit +the number of concurrently open streams on any single connection between a +client and the server. + +But this in itself is not good enough to protect the servers from too many +concurrent streams; a client can just create create more connections to the same +server, and be allowed to effectively send more concurrent streams. + +In addition to the overload risk due too many connections, another limitation of +a per-connection `MAX_CONCURRENT_STREAMS` is that it is static in nature. For +servers where the number of clients might be dynamic, this is sub-optimal. When +there are only a few clients connected to the server, the server might be able +to server more concurrent requests from each of these clients. So a +per-connection limit set to deal with overload situations (with 1000's of clients) +might be sub-optimal in situations with only a small number of clients. + +## Proposal + +Introduce `StreamQuota` as part of the `ResourceQuota` on the server side. Users +can set the `max_outstanding_streams` in the `StreamQuota`, which will be equally +distributed among all open connections to the server. If the user also specifies +a per-connection `MAX_CONCURRENT_STREAMS`, that will also be respected as an +upper bound. + +## Implementation + +Implemented in grpc/grpc#39125. From 7f4918c12855b21a2fa468304caa4fcbfcca0fb9 Mon Sep 17 00:00:00 2001 From: Siddharth Nohria Date: Wed, 14 May 2025 11:32:34 +0000 Subject: [PATCH 2/4] Update link --- L122-max-outstanding-streams.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/L122-max-outstanding-streams.md b/L122-max-outstanding-streams.md index 5f5687e44..cd493424d 100644 --- a/L122-max-outstanding-streams.md +++ b/L122-max-outstanding-streams.md @@ -40,4 +40,4 @@ upper bound. ## Implementation -Implemented in grpc/grpc#39125. +Implemented in https://github.com/grpc/grpc/pull/39125. From a9fcfce188832936cc8c92ce8366a78929760aff Mon Sep 17 00:00:00 2001 From: Siddharth Nohria Date: Wed, 14 May 2025 16:54:21 +0000 Subject: [PATCH 3/4] Update link --- ...ax-outstanding-streams.md => L124-max-outstanding-streams.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename L122-max-outstanding-streams.md => L124-max-outstanding-streams.md (96%) diff --git a/L122-max-outstanding-streams.md b/L124-max-outstanding-streams.md similarity index 96% rename from L122-max-outstanding-streams.md rename to L124-max-outstanding-streams.md index cd493424d..f0e867d34 100644 --- a/L122-max-outstanding-streams.md +++ b/L124-max-outstanding-streams.md @@ -5,7 +5,7 @@ Title * Status: Draft * Implemented in: C++ * Last updated: 2025-05-12 -* Discussion at: (filled after thread exists) +* Discussion at: https://groups.google.com/g/grpc-io/c/8HIUfWZewPo ## Abstract From 8d0ff75401770b523cfe05124cd87a3a75f098fb Mon Sep 17 00:00:00 2001 From: Siddharth Nohria Date: Tue, 17 Jun 2025 10:18:09 +0000 Subject: [PATCH 4/4] Rename file, add API documentations --- ...s.md => L124-core-max-outstanding-streams.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) rename L124-max-outstanding-streams.md => L124-core-max-outstanding-streams.md (78%) diff --git a/L124-max-outstanding-streams.md b/L124-core-max-outstanding-streams.md similarity index 78% rename from L124-max-outstanding-streams.md rename to L124-core-max-outstanding-streams.md index f0e867d34..7e6b6800d 100644 --- a/L124-max-outstanding-streams.md +++ b/L124-core-max-outstanding-streams.md @@ -38,6 +38,23 @@ distributed among all open connections to the server. If the user also specifies a per-connection `MAX_CONCURRENT_STREAMS`, that will also be respected as an upper bound. +### C++ API + +``` +// Sets the maximum number of streams corresponding to the ResourceQuota object. +ResourceQuota::SetMaxOutstandingStreams(int max_outstanding_streams) +``` + +### Core APIs + +``` +// Sets the maximum number of streams corresponding on the StreamQuota object. +StreamQuota::SetMaxOutstandingStreams(int max_outstanding_streams) + +// Returns the number of allowed concurrent streams on a given connection. +StreamQuota::GetPerConnectionMaxConcurrentRequests(int current_open_requests) +``` + ## Implementation Implemented in https://github.com/grpc/grpc/pull/39125.