This is on a shared server. Out of about 50 domains and subdomains hosted in my Dreamhost account, about 48 behave normally, but 2 show a repeatably strange phenomenon.
Which is, an unexplained delay of between 30 seconds and 2 minutes when a browser or curl requests a php file for the first time.
The php file is served normally, it's just terribly slow to arrive.
If there is a request for the same php file again within the next few minutes, then it is served without delay. But if there is inactivity for more than a few minutes before requesting the same php file again, then there is again approx one minute of delay like before.
NB it only happens in two of my websites out of more than 50.
One of the problem sites is on a shell user; the other is on an ftp-only user.
One of the problem sites is a domain; the other is a subdomain. The parent domain of the problem subdomain behaves normally.
One of the problem sites is the only site on its user; the other is on a user that contains several other sites all of which behave normally.
The delay applies only to php; one browser can be happily browsing html on a problem site while another browser, or curl, is being delayed while asking for php.
The strange behaviour has been consistent over the 5 days or so that I've noticed it, and I've been testing it a few times every day; it is always the same two websites which show the problem.
The php file on which I've been testing this is about as simple as it could possibly be, it is just
<?php echo "hello from mydomain.com"; ?>
The delay, insofar as I've observed it (which is a few dozen times by now), is always at least 30 secs and less than about 2 minutes.
The window of goodness within which a subsequent request is served normally appears to vary but is more than 5 minutes and less than 10 minutes. i.e. if I wait more than 10 minutes before trying again, then the problem will certainly return.
I've tried several alternatives, such as running a browser on my local machine while running curl on the server, and all combinations give the same result in terms of when there is or isn't a delay.
Just as an example, to show what I mean: if I request the php file in a browser on my local machine, and at the same time request it from curl on the server, then both requests are delayed, and both are satisfied within a few seconds of each other after a delay of one or two minutes;
but if I first request it from curl on the server, and wait for the delay to finish, and then request it from a local browser, the local request is satisfied immediately. And vice versa.
The delay happens even when I run curl on the same user as the problem site is on (in the case of the site which is on a shell user).
Checking the dns with http://www.intodns.com/ gives a clean bill of health for the problem domain, and for the parent domain of the problem subdomain (except for the "Recursive Queries" caution which I believe applies to all domains at Dreamhost)
This seems strange. Can anyone suggest what might be the problem?
P.S. another thing that might be worth mentioning, one of the problem sites is on 'PHP 5.2.x FastCGI' and the other is on 'PHP 5.3x FastCGI'.