dotnet / dotnet/aspnetcore

Kestrel: Is it possible for an app to control the lifetime/disposal of each request's IMemoryOwner?

Open
#21,385 5 comments 0 reactions 0 assignees View on GitHub
affected-very-few area-networking enhancement severity-nice-to-have
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is your feature request related to a problem? Please describe.
I'm looking for a way to use the byte buffers underlying the kestrel request stream and control when they get disposed. I couldn't find any way to stop kestrel from returning the bytes back to its' pool when the request ends.

### Describe the solution you'd like
A way to tell kestrel to not dispose/not reuse the byte arrays for any request (either on a per request basis; or a server setting). + a way to get the IMemoryOwner that has the request body.

### Additional context
This task is for a message bus that receives events on a HTTP API, queues them in an in-mem channel, and pushes them out to one or more user-configured HTTP endpoint/Service Bus topic /Event Hub namespaces.
(think eventgrid running in a single process, without persistence). Since the incoming request should not wait for the message to be pushed out on the other end, I end up copying the incoming request's bytes to my own pooled byte[] today and this takes a good 7-10% CPU.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.