#SharePointProblems | Koskila.net

Solutions are worthless unless shared! Antti K. Koskela's Personal Professional Blog

Solving Azure Web Application's first load performance issues

koskila
Reading Time 3 min
Word Count 399 words
Comments 2 comments
Rating 4 (1 votes)
View

Is your Azure Web Application suffering from absolutely horrible load times every time someone accesses it for the first time every 15 minutes or so? Mine was. It was pitiful.

I was developing a web-based service using EF6 and ASP.NET MVC 5, where all the assets were hosted in Azure. Even though the app was reasonably lightweight and usually responded very fast, the first time someone accessed it in a while it took 20-60 seconds to load AND sometimes even timed out (especially with mobile clients). Load testing revealed only what I already knew: initial load times were horrendous, but after that everything worked fine. I did eventually find the solution, though!

Solution - Adjust the minimum connection pool size of your Azure Web Application

I tried a few things, like enabling Always On and upgrading both the DB and Web app tier in the Azure management portal (from Basic to Standard). However, these actions had little to no effect on the timeouts. However, adjusting the connection string to add a "min pool size" to DB connections and presumably make them a little more long-living helped in my case.

In your config files, in the connection string -part (shown below), look for the "Min Pool Size=3"-part:

  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=....mdf;Min Pool Size=3;Initial Catalog=..." providerName="System.Data.SqlClient" />
  </connectionStrings>

I'll still have to test this a bit to find an optimal connection pool size, but already this change helped enormously.

What else can you do?

If you really, REALLY want to eliminate the latencies you get for the first load of the app service, you can prevent IIS from shutting down your process by making sure it doesn't hit the idle timeout that's set (internally) for the app service. In order to achieve that, just get a ping testing service to ping it every 5 minutes or so. This should prevent the process from shutting down, as I believe the default Idle Timeout is 20 minutes. You could also implement this yourself as a simple C# program running in a webjob, or even as a scheduled Flow making an HTTP request to your site.

I suspect this would be against Azure's EULA though... At least on Shared/Free tiers, you're kind of circumventing the missing "Always On" -switch, after all! It also kind of eliminates the whole idea behind infrastructure being used flexibly. Just something to think about.

Anyway, hope this helps!

Comments

Interactive comments not implemented yet. Showing legacy comments migrated from WordPress.
2019-03-13 03:17:53)
Thanks Antti. It helps to fix our web application problem.
2019-03-14 10:32:49
Hi Suresh! Thanks for the feedback, happy to hear that! :)
Whitewater Magpie Ltd.
© 2025
Static Site Generation timestamp: 2025-08-21T07:25:08Z