Kestrel: Is it possible for an app to control the lifetime/disposal of each request's IMemoryOwner?
- 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
Assessment
This issue has not been assessed yet.