Does anybody known any objections from using ASP.NET method Application_Start for application warm-up?
Especially, for web-services, where is usually required to preload files, caches algorithms and etc.
Exist:
- Service Auto Start Providers, serviceAutoStartProvider, https://weblogs.asp.net/scottgu/auto-start-asp-net-applications-vs-2010-and-net-4-0-series , where we need:
- Register new
serviceAutoStartProvider
, with concrete assembly name. - Assign
serviceAutoStartProvider
to IIS App. - Configure IIS App as AlwaysRunning.
- Register new
- IIS 8.0 Application Initialization , https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-application-initialization
- Assign
initializationPage
to IIS App. - Configure IIS App as AlwaysRunning.
- Assign
But, both methods require changes in IIS configuration for each application, what is uncomfortable in case with many-many applications and has additional risks on releases.
In accordance with ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0:
ASP.NET calls them (Application_Start and Application_End) once for the lifetime of the application domain, not for each HttpApplication instance.
Therefore, Application_Start seems like a great place for warm-up code, for example:
protected void Application_Start(object sender, EventArgs e)
{
Task.Run(WarmUpBackend);
}
It requires only configure IIS App as AlwaysRunning. In WarmUpBackend
we can preload everything what we need for web-services.