-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Routing] Significant performance regression when using a simple MapControllerRoute instead of MapGet on a bare-bones/starter .net 6 app (running on Azure App Service) #39250
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
Comments
The mvc pipeline is quite a bit heavier and more feature rich than the routing pipeline. There are things that can be improved in completely trivial examples but not bigger ones that support the extensibility that max controllers offer |
@davidfowl Many thanks for your comments! Just to make sure I'm understanding this fully: As soon as a developer opts for using a controller, even a trivial one, he/she simply has to accept this base performance hit and has no possibility to reduce it even partially, correct? For example, is there not some option to reduce the "heaviness" of the pipeline by overriding some configuration options, or even replacing the |
Thanks for contacting us. We're moving this issue to the |
Just to be sure I am doing the exact same repro can you confirm you are using https/h2 or plain http. |
@sebastienros yes it was https with h2 (note my app service config screenshot above). Let me know if you have any difficulty reproducing this! |
@samcic Can you reproduce this gap locally or only in app service? |
@davidfowl not to the same extent, no. See my comment on this in the original description above. It might however just be to do with the fact that I have a high end local machine. If this were an App Service only issue, do you have an idea for what could explain why it only happens there? From what I understand, the file system on App Service is backed by Azure Storage or something, so this is a random idea but could it be trying to load some assembly or something from the file system dynamically, on every request? App Service is of course somewhat sandboxed so I'm not quite sure how one could proceed to isolate what's happening there. I have an Azure standard support account if you think it'd be useful to create a ticket (I'm not aware of any other way to report such issues on App Service). |
Every request? No. If this is an app service only issue then at least we can spend more time looking there for the differences. |
I can't reproduce the problem. I used your application, but renamed the two endpoints Tried locally with http 1.1 and 2.0, and also on Azure with the S1 plan in WestUS2, on Windows. Used bombardier for 5s and 1 connection to measure latency only. I could measure the same latencies using Edge.
|
Can close this issue? It's been almost a year since the last feedback and we couldn't reproduce the problem by replicating the description. |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Is there an existing issue for this?
Describe the bug
Consider this bare-bones .net 6 app (Github repo linked below):
If I deploy this app to Azure App Service with "Option 1 (fast)" uncommented (i.e. using
MapGet
) and use the App Service Metrics blade to measure the average response time for sequential requests to/home/content
(with a 100ms wait between each request) over a time span of many minutes, the average response time is of the order of just a few milliseconds 👍 .If I then redeploy with nothing changed except for uncommenting "Option 2 (slow)" instead (i.e. using☹️ .
MapControllerRoute
), the average response time becomes of the order of 20 millisecondsIs this "by design"? That is, is this overhead of using this standard
MapControllerRoute
expected? Considering how simple this app is, I was quite surprised to see how much the average response time (for every request) increased when using Option 2, i.e. when invoking the controller-routing middleware.Is there anything that could be done for this bare-bones app to improve the performance of this
MapControllerRoute
option?Some related notes for context:
I have a much more complex .net core app deployed to App Service that interacts with various dependencies (e.g. database) and has an average production response time of between 40-50ms. The same test based on a copy of our production app (not included here) showed the same routing performance hit. That is, this routing performance hit of ~20ms for every requested controller action seems to be responsible for a significant portion of my average production response time. If there were a way to eliminate this ~20ms routing cost (while still using controllers) we could significantly optimize our response time.
On my local dev machine (a high-end ThinkPad X1), the average response time was 0.750ms for the
MapGet
case and 1.250ms for theMapControllerRoute
case (i.e. not quite as pronounced). The metrics shown above were from an App Service Plan at level S1, which is a "standard" Azure App Service plan level for production workloads.Using
MapDynamicControllerRoute
has similar performance toMapControllerRoute
.I tried both 32-bit and 64-bit App Service options (same results).
I also tried a .net 5 app with the same configuration (same results).
Expected Behavior
Although we of course understand that controller-based routing is more sophisticated, we would expect a simple app like this (i.e. a single controller) to not have such a performance regression for every request when using
MapControllerRoute
instead ofMapGet
.Steps To Reproduce
Minimal repo project:
https://github.com/samcic/WebApplication27
Exceptions (if any)
N/A
.NET Version
6.0.101
Anything else?
Azure App Service Test Environment:
App Service Plan Level: S1
IDE: VS2022 17.0.4
The text was updated successfully, but these errors were encountered: