0

I’m developing a Laravel website which is to be deployed to Windows Server 2019 (IIS) running SQL Server, hosted on a VPS with Plesk.

I recently deployed the site to a password-protected testing subdomain on the server to make sure everything works and see how speeds are when mimicking a production environment on the actual server. Generally, speeds are perfectly satisfactory: full-page response times are around 200–800ms.

However, if I haven’t visited the site for a while (don’t know exactly how long – an hour will certainly do it), then the first request I make to the test site is very slow, usually 10+ seconds, sometimes 30+ seconds. Any subsequent requests are very fast and responsive, even from a different device on a different network, so it’s not a client issue.

On a different domain, the server also hosts a live production site primarily written in Classic ASP (VBScript), but also with some parts in plain (non-framework) PHP, which is not affected by this issue. All requests to the live site load at similar speeds, with no slowdown on first requests. There is a different password-protected testing subdomain which hosts a copy of the live site, and this is also not affected. When running from my dev machine (a Mac), I use the live database on the server, and there’s also no delay for first requests there, so it’s not a database issue.

I have made sure to set the application pool’s start mode to alwaysRunning to at least rule out that firing up a new worker process is the culprit. The server is quite low-traffic, so the answer to this question doesn’t apply.

The issue is overall very similar to this question, except that mine isn’t a .NET application so neither of the two answers given there applies. I’ve seen people mention caching as well, but always in relation to the caching of just-in-time compilations of ASP/.NET apps, which wouldn’t be relevant to a PHP app either.

I would really like to try to figure out exactly what is taking such a ridiculously long time on this one subdomain/application (and, obviously, fix it), but I have no idea how.

So basically my question is two-fold:

  • Is there a way in IIS to ‘clock’ requests and find out where in the request process the bottleneck is?

  • If not, what are some likely factors I should be looking at for things that might cause this type of first-request delay?

 


Please let me know if I’ve left out some vital server details. I’m not a professional server admin, and I only just barely know my way around Windows Server to begin with.

1 Answers1

1

This is classic application pool starting behavior.

Did you make sure you changed the “Idle Timeout” setting of the application pool?

If not, it will shut down after 20 minutes of inactivity and the next request is going to take longer.

Or, have you checked the recycling setting of the app pool? A recycle will also cause this problem.

The app pool start mode setting is not going to solve your problem.

https://stackoverflow.com/questions/64818322/application-pool-start-mode-ondemand-vs-alwaysrunning-which-the-best

Appleoddity
  • 3,290
  • 2
  • 10
  • 27
  • The _Idle Timeout_ setting was set to 5 minutes. I’ve now changed it to 1740 (what the _Regular Time Interval_ is set to). That should keep it running for as long as possible, I assume? I’ve also changed the _Idle Time-Out Action_ from `Terminate` to `Suspend`, which should make it faster if it ever does idle-timeout, right? Which recycling settings should I check? There are quite a few of them, and I can’t really gauge what any of them do (_Disable Overlapped Recycle_, _Specific Times_, etc.). – Janus Bahs Jacquet Aug 02 '22 at 07:58
  • Hm, changing those settings, then restarting IIS and visiting a page on the website didn’t fix it – loading time was still 25 seconds on first visit. – Janus Bahs Jacquet Aug 02 '22 at 08:04
  • @JanusBahsJacquet you just turn recycling off, as in don’t schedule it. The “first” time you access the site after starting IIS it’s always going to do that, but it should not keep doing that after not accessing it for a while. – Appleoddity Aug 02 '22 at 12:47
  • Erm, how do I do that? There’s a _Disable Overlapped Recycle_ setting and a _Disable Recycling for Configuration Changes_, but nothing that looks like it disables recycling completely. Unless those two are the only forms of recycling there are? – Janus Bahs Jacquet Aug 02 '22 at 12:59
  • @JanusBahsJacquet No. not those options. Disable the “scheduled” recycle by setting regular time interval to 0 and deleting anything in ‘specific times.’ You may also be interested in the private memory limit, request limit etc. these are all triggers for a recycle. – Appleoddity Aug 02 '22 at 13:07
  • Ah, I didn’t think that was possible (when I changed the _Idle Timeout_ setting before, it told me that that had to be less than the _Regular Time Interval_, so I’d assumed I wouldn’t have been able to set _Regular Time Interval_ to 0… but I could. Restarted IIS (is that actually needed?) and as you say, the first load after a restart was slow (~10 seconds); now waiting a while to check if these settings together have fixed the delay-after-X-minutes thing. – Janus Bahs Jacquet Aug 02 '22 at 13:16
  • Seems to be working – a few hours later, and the first load responded in 495 ms! Thank you! – Janus Bahs Jacquet Aug 02 '22 at 14:46