Alternative to application pool startMode="AlwaysRunning"
If a web application called for itself to be setup with it's application pool to be configured in the applicationHost.config as:
<add name="AppPool" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
Would the same result be achieved by just requesting a page from the server every minute? Or does setting startMode to this value have other implications also?
Solution 1:
It appears to be the same. Seemingly, since Microsoft saw developers having to do this, they created this new feature to automatically handle this.
[Developers] then either devise custom scripts to send fake requests to the application to periodically “wake it up” and execute this code before a customer hits it, or simply cause the unfortunate first customer that accesses the application to wait while this logic finishes before processing the request (which can lead to a long delay for them).
ASP.NET 4 ships with a new feature called “auto-start” that better addresses this scenario, and is available when ASP.NET 4 runs on IIS 7.5 (which ships with Windows 7 and Windows Server 2008 R2). The auto-start feature provides a controlled approach for starting up an application worker process, initializing an ASP.NET application, and then accepting HTTP requests.
From Scott Guthrie's Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series).
So unless you're not using IIS 7.5, I'd say just use the built-in functionality.
(And thanks; I didn't know about this feature, but can definitely think of sites that I develop for that could use it.)
Solution 2:
IIS 7.5 includes an additional flag on a Site or Application level called preloadEnabled
. Setting this to true will create a fake request to warm up the site. It must be used in conjuncation with autoStart
.
autoStart
<add name="{yourapppoolname}" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" startMode="AlwaysRunning" />
preloadEnabled
<site name="YOURSITENAMEHERE" id="4″>
<application path="/" applicationPool="YOURAPPPOOL" preloadEnabled="true">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\YOURSITENAME" />
</application>
</site>