Search code examples
azureasp.net-coreazure-virtual-machineazure-web-app-servicenopcommerce

Azure App Service slow compared to Azure VM


I have an ASP.NET Core system (based on NopCommerce framework) hosted on Azure VM (Standard F8s_v2 size). The application runs pretty smooth. Average response times are around 200 ms which is acceptable. Very same application was hosted on Azure App service (P2v2 plan). It is noticeably slower. Average response time is around 500 ms.

I did tons of monitoring profiling:

  • CPU on both Azure App service and VM is low. A single request gets CPU at around 5% on App service and around 3% on VM.
  • Upgrading App Service plan has zero effect.
  • There are no memory usage spikes neither on VM nor on App service
  • IO is close to non-existent on both VM and App service.
  • Both VM and App service got their own databases. Both of them were swapped when trying to figure out details of this behavior. No difference in behavior.
  • All resources are on hosted on the same region.

Nothing really suggest this being a resource related performance issue on App service.

I got this profiler trace when profiling App service: App service profiling

The application has built in profiling, implemented with MiniProfiler. The comparison of calls to identical endpoints on VM and AppService can be found here: VM vs App service profiling

What could be causing this slowdown on App Service? What else is worth checking that would provide any hints on why response times are different?


Solution

  • The actual problem of this the way application as hosted. Project settings would use outdated AspNetCoreModule as well as hosting model. Forcing it to use ASP.NET Core 2.2 new inProcess hosting model resolved the issue. If you are interested in more intricate details of why it runs faster you could read this