-
Notifications
You must be signed in to change notification settings - Fork 419
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
New configuration parameter for HTTP2 maxFrameSize. #1253
Conversation
|
5c9a02a
to
0faa956
Compare
Sources/GRPC/Server.swift
Outdated
private func clamped<T>(_ value: T, lower: T, upper: T) -> T where T : Comparable { | ||
return min(max(value, lower), upper) | ||
} |
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 can be expressed a little more Swift-ly as:
extension Comparable {
fileprivate func clamped(to range: ClosedRange<Self>) -> Self {
return min(max(self, range.lowerBound), range.upperBound)
}
}
Sources/GRPC/Server.swift
Outdated
/// inclusive. | ||
public var httpMaxFrameSize: Int = 16384 { | ||
didSet(httpMaxFrameSize) { | ||
self.httpMaxFrameSize = clamped(httpMaxFrameSize, lower: 16_384, upper: 16_777_216) |
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.
The upper-bound is off-by-one here; the upper limit should be 2^24 - 1.
Sources/GRPC/Server.swift
Outdated
@@ -332,6 +332,14 @@ extension Server { | |||
} | |||
} | |||
|
|||
/// The HTTP/2 max frame size. Defaults to 16384. Must be value between 2^14 and 2^24-1 octets | |||
/// inclusive. |
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.
Could you add a note saying that we clamp the value if it's outside the range?
0faa956
to
4ceab7f
Compare
Motivation: In gRPC calls that process large payloads, the default settings of the HTTP2 maxFrameSize (16384) within swift-nio-http2 results in significant performance impact (for large payloads this performance impact has been demonstrated to result in timeouts where RPCs fail to complete within their assigned deadline). Allowing programmatic configuration of the HTTP2 maxFrameSize when the server is built allows the parameter to be optimised for the expected payload sizes. Modifications: Added new gRPC configuration parameter for the HTTP2 parameter maxFrameSize (which can be configured in the Server.Builder using the new method `withHTTPMaxFrameSize()`). Result: The Server.Builder can be used to configure the HTTP2 maxFrameSize parameter as: Server.insecure(group: serverGroup).withHTTPMaxFrameSize(1024 * 1024)...
4ceab7f
to
dc40e0b
Compare
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, thanks @gcjenkinson!
Motivation: Having more control over the configuration of the http/2 layer is useful for certain performance sensitive situations. We recently exposed the max frame size setting on the server (grpc#1253); we should do the same on the client. Modifications: - Add configuration for the max frame size to the client - Fix the clamping of the max frame size on the server (this was missed when reviewing grpc#1253) - Add tests to validate that the configured values are correctly clamped - Send `SETTINGS_INITIAL_WINDOW_SIZE` in the initial SETTINGS frame set to the value of the target window size. Result: Users have more control over HTTP/2 settings.
Motivation: Having more control over the configuration of the http/2 layer is useful for certain performance sensitive situations. We recently exposed the max frame size setting on the server (#1253); we should do the same on the client. Modifications: - Add configuration for the max frame size to the client - Fix the clamping of the max frame size on the server (this was missed when reviewing #1253) - Add tests to validate that the configured values are correctly clamped - Send `SETTINGS_INITIAL_WINDOW_SIZE` in the initial SETTINGS frame set to the value of the target window size. Result: Users have more control over HTTP/2 settings.
Motivation:
In gRPC calls that process large payloads, the default settings of the
HTTP2 maxFrameSize (16384) within swift-nio-http2 results in significant
performance impact (for large payloads this performance impact has been
demonstrated to result in timeouts where RPCs fail to complete within
their assigned deadline).
Allowing programmatic configuration of the HTTP2 maxFrameSize when the
server is built allows the parameter to be optimised for the expected
payload sizes.
Modifications:
Added new gRPC configuration parameter for the HTTP2 parameter
maxFrameSize (which can be configured in the Server.Builder using the
new method
withHTTPMaxFrameSize()
).Result:
The Server.Builder can be used to configure the HTTP2 maxFrameSize
parameter as:
Server.insecure(group: serverGroup).withHTTPMaxFrameSize(1024 * 1024)...