Skip to content
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

Kestrel gRPC support: provide more efficient APIs for reading request and response bodies #4697

Closed
jtattermusch opened this issue Nov 5, 2018 · 6 comments
Assignees
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel
Milestone

Comments

@jtattermusch
Copy link

One of the possible ways how to integrate with gRPC is to write a generic handler that reads http request's body (httpContext.Request.Body) and parses them into grpc request messages and writes grpc response messages into httpContext.Response.Body. This works pretty well (see prototype in https://github.com/jtattermusch/grpc-aspnetcore-experiments), but both request body and response body are instances of System.IO.Stream, which works but isn't particularly efficient (e.g. copying of the data is required, it's hard to use with memory pooling etc.) and will probably become a performance bottleneck in the future.
Is there a way to access request and response bodies e.g. in terms of the new System.IO.Pipelines API?

Context: grpc/grpc#15139

@muratg
Copy link
Contributor

muratg commented Nov 5, 2018

cc @davidfowl

@davidfowl
Copy link
Member

Yes, there are plans to get this done for ASP.NET Core 3.0.

@JunTaoLuo JunTaoLuo self-assigned this Nov 6, 2018
@Tratcher
Copy link
Member

Tratcher commented Nov 6, 2018

In addition to making the pipes available we'll also need to make every middleware that wraps the body at least partially pipes aware. E.g. Anything that wraps the body must also wrap the pipe, or replace one or the other with a redirector. See Response Compression, Response Caching, etc.. This is similar to how they handle or redirect ISendFileFeature today.

@davidfowl
Copy link
Member

Yes, this is a know design challenge.

@aspnet-hello aspnet-hello transferred this issue from aspnet/KestrelHttpServer Dec 13, 2018
@aspnet-hello aspnet-hello assigned JunTaoLuo and unassigned JunTaoLuo Dec 13, 2018
@aspnet-hello aspnet-hello added this to the 3.0.0 milestone Dec 13, 2018
@JunTaoLuo JunTaoLuo assigned jkotalik and unassigned JunTaoLuo Jan 25, 2019
@JunTaoLuo
Copy link
Contributor

I think @jkotalik is actively involved with this work. Please reassign if that's not the case.

@jkotalik
Copy link
Contributor

jkotalik commented Mar 5, 2019

The base layer for this is done with #7603 and #7110. Counting this as done.

@jkotalik jkotalik closed this as completed Mar 5, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions feature-kestrel
Projects
None yet
Development

No branches or pull requests

9 participants