Search code examples
phpiis-7.5

IIS needs a moment to wake up, gives error 500 until then


I have a PHP application that utilizes OPcache and a laravel like library octoberCMS.

When I request a site that hasn't had requests for a while(15 minutes or so, or 30, not really sure), IIS always seems to need a while to "wake up" the first 15-20 seconds I only get error 500, then when IIS is awake again every works as it it's intended.

Is there a setting in the php.ini I need to change to account for IIS wake up time to load all scripts or a setting in IIS to first properly wake up before trying to serve the page?


Solution

  • You can use application initialization module in IIS to show the user a splash page while your application is being compiled in the background. The splash page will be shown only to the first request after an application pool has been recycled or an iisreset is performed.

    https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-application-initialization

    In your case, I believe the application pool is getting recycled. Default idle time out period of application pool is 20 minutes. It basically kills the w3wp process. Hence, for first request after the time out, a new w3wp process is launched which initially takes some time to load modules.