-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Configure HTTP/2 receive window size #49897
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackground and MotivationCurrent HTTP/2 receive window size is 64 Kb, which is too small for many scenarios. It leads to poor throughput, see e.g. #43086 Just increasing the default window size may result in unwanted memory consumption in some cases. It is proposed to enable users to configure that so they can reach a compromise between memory consumption and throughput. Proposed APIpublic sealed partial class SocketsHttpHandler
{
...
public bool EnableMultipleHttp2Connections { get; set; }
+ public int InitialHttp2StreamWindowSize { get; set; }
}
|
How is the initial connection window size currently determined? Should that also be configurable? |
Connection's window size is 64 Mb. I guess configuring it makes sense, in case you would want a really big stream window, so connection window won't become a bottleneck... I'll add that |
Should we also consider the size of the increments? So to achieve similar window update sizes (32KB) one would need to raise this value 4x to 256KB... |
Are these configuration settings designed to allow good performance by default, or are they for advanced users to tune performance? I believe the HTTP/2 functionality in Grpc.Core (which uses a C++ HTTP/2 stack) has good performance without having to tune this configuration. Ideally SocketsHttpHandler would be the same. If we make devs change these settings, most aren't going to know to and will continue to have HTTP/2 perf issues with large requests. |
@JamesNK we intend to update the defaults so it will allow good performance in most of the cases without the need to change anything. The main reason for these settings is to be sure that we will not break/block anyone with our suddenly increased defaults and they could set it to something smaller. And as a second reason we'll have some advanced tuning for those who are interested. |
[API] The proposal started with 1 property, now we have 3 :) How would the introduction of the dynamic window algorithm impact this API? Will there be a new bool property to turn it on/off? Are the properties |
@antonfirsov all of the properties will make sense even with an introduction of the dynamic algorithm. New properties for turning dynamic algorithm on/off or other configs might appear, however, it's better to discuss them separately when we decide to implement dynamic algorithm. |
In this case, wouldn't it make sense to extract the properties to a separate Personally, I dislike how |
Separate public sealed partial class SocketsHttpHandler
{
...
public bool EnableMultipleHttp2Connections { get; set; }
+ public Http2FlowControlOptions? Http2FlowControlOptions { get; set; } = null;
}
+public class Http2FlowControlOptions
+{
+ public int InitialConnectionWindowSize { get; set; }
+ public int InitialStreamWindowSize { get; set; }
+ public int StreamWindowUpdateRatio { get; set; }
+} I personally don't see a better place to put these options. |
I didn't mean to have them in another place :) I just don't understand why do we prefer the current flat structure instead of defining separate option classes for different configuration concerns. I think if a group contains 3+ related properties, it makes sense to extract it to a separate class, but not sure if others share my opinion. |
Personally, I think we should stick with just a single property, runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs Lines 85 to 88 in f690d59
So just making it higher than stream should suffice. And for the ratio, we could follow Kestrel's lead and just change the 1/8 to 1/2. |
If we allow to change only I believe it is not enough to just have connection's window bigger that a stream one, as there could be many streams in one connection. As for the ratio, as it does not affect memory consumption, only performance - I'm ok with not exposing it for now. |
At a minimum we need We need to define the new default value for this property as part of this proposal. I don't have a strong opinion re That said, since we are exposing the stream window size, it's reasonable to expose the connection window size too, for completeness if nothing else. |
Regarding update ratio: I don't think we should expose this. I think we should be able to just do the right thing here without user input. And I'm not sure how the user would reason about how to set this. Consider also there are possible optimizations we could make here in the future, like proactively sending window update frames with other frames we are sending anyway; if we did this, it's not clear what the user "update ratio" setting means in this model. As to what we should set this to: We chose 1/8 in order to try to ensure some reasonable amortization of the cost of sending a window update, while minimizing impact on the effective window size. This still seems like a reasonable value to me, though if we have perf data otherwise we could tune it. In particular, I am not sure why ASP.NET chose 1/2; this seems pretty large to me. @JamesNK @halter73 thoughts here? |
I've added "Initial" so it would still make sense in case dynamic algorithm will be added. But it is also called "Initial" in SETTINGS frame ( |
Yeah, but in the SETTINGS frame it specifically is the initial window size, and the ongoing window size is controlled by sending window updates. |
Triage: Based on discussion, we should wait with this until we have the dynamic window update, then decide if parts/all is needed at all in .NET 6. |
Closing this in favor of #53372 |
Background and Motivation
Current HTTP/2 receive window size is 64 Kb, which is too small for many scenarios. It leads to poor throughput, see e.g. #43086
Just increasing the default window size may result in unwanted memory consumption in some cases. It is proposed to enable users to configure flow control properties that so they can reach a compromise between memory consumption and throughput.
Proposed API
The text was updated successfully, but these errors were encountered: