Django + FastCGI app on Azure, frequent restarts

518 views Asked by At

Is there a way to stop Azure + wfastcgi restarting a Django app?

I have 2 different apps running on Azure, both using Django 1.7.8 with the wfastcgi.py adaptor. These are web apps using standard pricing. Both appear to restart quite frequently (every 10 minutes or less) under light load, when no code changes have happend. This is annoying because a new request after a few minutes of inactivity will take several seconds while the app starts up.

I was expecting the Azure + FastCGI adaptor to keep an app loaded in process, potentially for hours and days at a time. Does Azure just unload a site automatically? Both sites are configured with a minimum instance count of 3.

2

There are 2 answers

0
theadriangreen On

Try enabling the "Always On" feature, this can be done via the web app settings.

How Azure websites works is that the site content is stored on a file server, and then the site is loaded by a web worker when it is active. If the site is idle it will be unloaded, causing a restart. Always on means that your web app is always loaded.

Documentation for configuring web apps is here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/

0
Michał Smereczyński On

The problem is much more complex than "Turn on Always On option". I faced this problem, resolved and described on my blog: https://lnx.azurewebsites.net/python-app-on-azure-web-apps-frequently-restarts/