Recently, I implemented Application Initialization in one of our Azure projects in order to minimise the time it takes for each of the sites to warm up.
I essentially have implemented near exactly the steps outlined in This blog post.
On a fresh deployment, it works for all 10 of my sites in IIS. The problem is though, when I then try and Upgrade that deployment I get 500 errors for the first 25 requests or so for each site.
Now, this isn't ideal, as instead of hitting each site once to warmup after a deployment, I now have to load each site around 25 times before I get past the 500s. They don't stop there though, they seem to sporadically happen.
If I re-image the machines post-deployment, that fixes the issue. At the cost of downtime though, which isn't an option.
Any ideas?
I have the following:
Startup task in ServiceDefinition.csdef to turn on the Application Initialization Module:
<Task commandLine="enableApplicationInitializationIIS.cmd" executionContext="elevated"></Task>
Then inside that task I have:
PKGMGR.EXE /iu:IIS-ApplicationInit
In the ServiceConfiguration.csfg I have set up the latest osFamily
:
<ServiceConfiguration serviceName="Foo" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2012-10.1.8">
Then in the Web Role, I have the following to turn on all the Application Initialization required settings:
public class WebRole : RoleEntryPoint
{
public override bool OnStart()
{
using (var serverManager = new ServerManager())
{
foreach (var site in serverManager.Sites)
{
foreach (var application in site.Applications)
{
application["preloadEnabled"] = true;
}
site.ServerAutoStart = true;
}
serverManager.ApplicationPoolDefaults.ProcessModel.IdleTimeout = new TimeSpan(00, 00, 00);
serverManager.ApplicationPoolDefaults.Recycling.PeriodicRestart.Time = new TimeSpan(00, 00, 00);
serverManager.ApplicationPoolDefaults["startMode"] = "AlwaysRunning";
foreach (var appPool in serverManager.ApplicationPools)
{
appPool["startMode"] = "AlwaysRunning";
}
serverManager.CommitChanges();
}
return true;
}
}
And finally, each of my sites have the following:
<system.webServer>
<applicationInitialization skipManagedModules="true">
<add initializationPage="/" />
</applicationInitialization>
</system.webServer>
Not sure what skipManagedModules
is though?