Dash App on Azure App Services takes ~30 seconds to load for the first time

My dash app on Azure App Services takes about 30 seconds to load. But then if I close it and open it up again, relatively soon, it loads instantly. If I wait to open it again for an hour or so then it takes about 30 seconds to load again.

My initial load is only establishing an SQL connection and creating a drop-down menu with a list of clients to choose from. This takes about a second to load on my local.

I am using the Azure Free Tier. Would upgrading to Basic Tier and turning “Always On” solve this issue? Are there any other ways to solve this issue without upgrading to Basic Tier?

Hi @MapMan2020,

I had the same issue with one of my apps after switching to the F1 (free) tier. Before I was on B1 and I did not observe this issue.

I think that what is happening is that if your app does not receive any requests for a certain amount of time, azure will kill it. After that, the first request takes a loong time because the app has to start again. You can observe this when, in portal.azure.com, you go to Search -> App Service plans -> your service -> CPU percentage graph. You will observe down periods in the cpu utilisation - this is when your app is down.

1 Like

Yep, i switched to basic tier and turned on “always on” now it loads insantly everytime.

I am curious though, why does it take so long to load initially without being on Basic Tier with “always on” enabled? What’s happening behind the scenes? On my local windows machine, it always loads very quickly without me having to do anything special. So is this initial load time issue a Linux thing? a Cloud thing? A flask thing? Does this happen on other hosting platforms?

I ask because management is very impressed with what I’ve built with Dash so we’re going to start moving some of what we do in Tableau over to Dash. Not that having to pay for Basic Tier is that big of a deal, but I still need to be able to understand and explain why. Understanding this will become increasingly important as we scale up and build more Dash Apps and push them to Azure for production.

It’s probably worth mentioning that I am new to programming (this is my first project) and none of the software engineers at my company know Python.

I only have experience with Heroku, but what they do is to shut down the container when it has not received requests for some amount of time (e.g. 30 minutes), similar to when your pc goes into standby. They do this to save computational resources. When a new request arrives to the app, the container must be started before the app can load, which takes around 10 seconds. My guess is that Azure uses a similar approach.

The delay is thus not related to Dash, nor Linux, but simply to the way your cloud provider chooses to mange their resources. As you have already noted, paying them to keep the app online (Basic Tier + “always on”), you can avoid the delay.

1 Like

Thank you both, that makes sense.

@sislvacl I see that you explained it too but I missed the second half of what you wrote since I read it on my phone :sweat_smile: