The end goal is to make it so that whenever my app pool is recycled (which should happen whenever I release an update for the site), my site gets visited once to "warm up". Typically the first visit after a recycle takes 2.5 seconds and then subsequent visits only take 0.5 seconds so it needs to be visited once after every update. I'd like to automate that and it seems the Windows Application Initialization feature is the way to do that.
The problem is that, with this feature enabled, upon restarting the app pool (or restarting anything) I'm not seeing any access logs of a visit to my site. It seems like the Application Initialization feature isn't functioning at all. I don't see any errors in the system event log or any way to troubleshoot further.
Here's the environment:
- Windows Server 2019
- IIS 10 (with all needed roles/features)
- ASP.NET Core 3.1
Here's what I've configured (using the IIS 8.0 Application Initialization guide):
- The "Application Initialization" feature/role has been installed in Windows
- App Pool:
- .NET CLR version: No Managed Code (I've also tried v4.0)
- Managed pipeline mode: Integrated
- Start application pool immediately: Enabled
- Start Mode: AlwaysRunning
- Idle Time-out (minutes): 0
- Regular Time Interval (minutes): 0
- Site:
- HTTPS only (I've also tried adding HTTP)
- Preload Enabled: True
- applicationHost.conf file
system.webServer/applicationInitialization
section:
Troubleshooting:
- I've restarted the site/app pool/services/server
- I've tried various settings in the
system.webServer/applicationInitialization
section and also moving it to web.config - I noticed that the
globalModules
section of the applicationHost.config file had this in it but I've browsed to that folder and it's empty. I would have expected some dll files in there including warmup.dll:
<add name="ApplicationInitializationModule" image="%windir%\System32\inetsrv\warmup.dll" />
If your website uses a database it may be that the problem is there, the connection to the database is only made on the first request most of the time, database version checks are made at that time too, which you can do if it takes a while, check that right after the recycle the connection is still active, if it is not active, make it start with the pool, this should help.
(automatic translator, please disregard spelling errors)
It seems like there must be some incompatibility between the IIS Application Initialization feature and ASP.NET Core 3.1 sites because it doesn't work at all and there doesn't seem to be any way to troubleshoot.
So I've decided to drop IIS in-process hosting altogether and instead host Kestrel inside a Windows Service Worker Service.