I'm attempting to diagnose a performance issue on a Drupal website I'm developing. In the morning, when the site has seen no traffic (not even a cron run) for over 8 hours, the homepage takes around 3.5 seconds to load. Reloading the page takes an expected 250ms.
This is a development web server, with a fairly old version of PHP installed (5.3.3). All of the files are statically mounted over NFS (which I believe is the root cause, more on that below).
To help diagnose, I installed XHProf on this development server, and enabled a Drupal module that profiles page loads and displays the profiling data in a nicely sortable table. For those unfamiliar with XHProf, it provides data on every function called and things like the total time spent, memory usage, and calls for that function.
On the initial "slow" hit, the PHP function
file_exists took 1400ms from 82 calls, accounting for roughly 43% of the total execution time. On the subsequent page load, the same function
file_exists was again called 82 times, but this time it was dramatically reduced to just 3ms accounting for just 1% of the total execution time.
I additionally looked at the file that took the longest for PHP to load into memory (which is what I believe the
load:: prefix means on a function name). This PHP template file took a whopping 42ms to load the first time around, and only 3ms on the subsequent reload!
What I suspect
It's clear to me there is some sort of caching going on somewhere - I just don't know where yet. The PHP docs for file_exists mention that the output of this function is cached. I then found I can control the size of this cache and it should probably be increased from the default 16k to something more appropriate for Drupal (which loads tons of relative files).
However, while I think that would reduce the amount of time spent in
file_exists, I'm not sure that will affect the time PHP takes actually loading the file (the
load:: I mentioned earlier) and increasing this value seems to just be hiding underlying performance issues with the file system.
- If there are any XHProf or PHP veterans that can confirm if the increasing PHP's
realpath_cachehad any impact on the time reported in
- What underlying caching mechanisms should I be aware of in Linux that could have an impact?
- Same as above, but for NFS?