0

(I am unsure whether this is the correct site for this question. If it is, please feel free to remove this disclaimer, otherwise just ping me, I will move and delete it then...)

We are deploying an angular application that has been created using the Angular-CLI toolset to an Azure WebApp. Loading a static file with about 500 KB from a browser takes a good seven seconds in this setup.

When delivering the same file using an ASP.NET Core web application and the app.UseStaticFiles() middleware, the load time drops to less than 200 ms.

Am I missing something about Node.js serving static files here? Can anyone point me at what we did wrong here?

Spontifixus
  • 6,570
  • 9
  • 45
  • 63
  • Node's js VM is slower than .NET's CLR compiled code perhaps? Those load times seem really slow, are you sure it isn't network inconsistencies? – Mardoxx May 10 '17 at 22:15
  • 1
    Is this the first time you visit your website? If yes, Azure needs time to warm it up (maybe 10+ seconds). See [windows azure website load time](http://stackoverflow.com/questions/15730557/windows-azure-website-load-time) – Aaron Chen May 11 '17 at 05:38
  • @AaronChen-MSFT: No we tried several times, discarding the results of the first time load. Also when using ASP.NET Core sometimes (about one in 20 tries) the load time rises to about 2 to 4 seconds, but mostly is between 150 and 300 ms. We tested this with one WebApp in an S1 and S3 App-Service-Plan. – Spontifixus May 11 '17 at 06:31
  • @Mardoxx, The network is fine, we tested this both independently from Azure as well as with files delivered by ASP.NET Core. – Spontifixus May 11 '17 at 06:32
  • Could you share some code snippet of Node.js? – Aaron Chen May 11 '17 at 06:51
  • @AaronChen-MSFT I have some difficulties reproducing this issue on a clean WebApp. This is however an angular application generated with the Angular CLI, and a bunch of third party npm packages included, which results in a vendor.js file of about 2 MB, which gets zipped on its way to the browser resulting in a download of around 500 KB. – Spontifixus May 11 '17 at 14:22
  • I'm curious to know why you don't use IIS to serve static files. IIS has been built in Azure Web Apps. – Aaron Chen May 11 '17 at 15:10
  • Were you comparing the scenario between node.js+Angular and ASP.NET+Angular ? Have you tested the performance individual node.js and ASP.NET server without any frontend framework? Further more, could you kindly provide your code snippets for investigation. – Gary Liu May 31 '17 at 01:14

1 Answers1

2

We found the problem. The app is hosted using IIS and not with Node.js. It's the way how IIS transfer and compress the JS files, see the answer here: Azure Website slow to serve static JS/CSS but not binary

We added the following line to <system.webserver> in web.config

<serverRuntime enabled="true"  frequentHitThreshold="1"  frequentHitTimePeriod="00:00:20" />

which solved the problem (~8-10 seconds to now ~200 milliseconds).

Spontifixus
  • 6,570
  • 9
  • 45
  • 63
Martin
  • 198
  • 2
  • 5