-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
#827 #1679 Improve performance of Request Mapper #1724
#827 #1679 Improve performance of Request Mapper #1724
Conversation
@raman-m this is largely inspired by yarp. |
|
I'll review this PR after documentation release... OK? |
Yeah fine, I will check the performance with 1-2 benchmarks first. |
@raman-m Ok, code is now review ready. |
Will this PR fix #749 ? |
Add "Maximum request body size" notes
244883e
to
b669552
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.
Ready for delivery! ✔️
Thanks Gui for your efforts! 😍
This will be the brilliant feature of November'23 release! 💎
We've had this PR in production for 5 days (plus a trial run a few days earlier), it's working well, and we haven't had any Out of Memory issues, or even a slightly lower memory footprint from the app. |
Fixes #1679 #827
Proposed Changes
https://github.com/microsoft/reverse-proxy/blob/main/src/ReverseProxy/Forwarder/StreamCopyHttpContent.cs
@raman-m @RaynaldM I have written a new benchmark, called payload benchmarks (part of PR too). We send various payloads (empty, 25, 50, 100, 1000, 5000, 10000, 20000 json objects), which involves the use of RequestMapper, and evaluate performance and memory usage. I checked that the target client was receiving the payload.
@raman-m @weichaohh As a colleague pointed out, I didn't address the issue of smaller payloads with a length < than the Default Buffer Size. Therefore I have added smaller payloads to the benchmark's payloads. Some are smaller than the Large Object Heap threshold, 85KB. So I modified the copy logic, and made sure that the default buffer size was only used when the promised / announced content length was >= than the Default Buffer Size.
First I have checked the performance of the develop branch code:
Figure 1: develop branch code
And then I checked the results of this PR
Figure 2:PR code
As you can see, we have a performance gain, but also lower memory usage.
Worst case: 92 MB vs 977 KB for the 20'000 objects payload