PHP’s realpath_cache is a small per-process cache of resolved filesystem paths. Every include, require, and file_exists call involves resolving symlinks and walking the directory hierarchy to canonicalize the path. The realpath cache memoizes that walk. The default realpath_cache_size of 16K and realpath_cache_ttl of 120 seconds were set when typical PHP apps had a few dozen files. Modern Composer-laden Laravel or WordPress with many plugins easily hits the cache limit on every request — and pays the resolution cost on every miss.
What’s happening
When PHP processes require '/vendor/autoload.php', it walks the path /, /vendor, /vendor/autoload.php, checking that each component is a directory (or the final is a file) and resolving any symlinks. On a deep vendor/ hierarchy, this can be 30+ syscalls per include. The realpath cache stores the resolved path and skips the walk on subsequent calls. When the cache fills up, the oldest entries get evicted and the syscalls happen again.
A WordPress site with 30 plugins commonly includes 2000+ files per request. A Laravel app with full vendor/ tree includes 4000+. With the default 16K cache, only a fraction of those paths fit, and every request re-resolves the misses.
How to verify
Current settings and cache state:
/opt/cpanel/ea-php82/root/usr/bin/php -i | grep realpath_cache
/opt/cpanel/ea-php82/root/usr/bin/php -r 'var_dump(realpath_cache_size()); var_dump(realpath_cache_get());'
The realpath_cache_size() function returns the bytes currently used. If it equals or exceeds your configured limit, the cache is full and evicting. The realpath_cache_get() returns the actual cache contents — useful for confirming the right files are cached.
For a live test of impact, time an include-heavy operation with both settings:
time /opt/cpanel/ea-php82/root/usr/bin/php -r 'for ($i = 0; $i < 100; $i++) { include "/path/to/heavy-includes.php"; }'
Run with default and with raised values; compare.
The fix
In /opt/cpanel/ea-php82/root/etc/php.ini (or per-version equivalent):
realpath_cache_size = 4096K
realpath_cache_ttl = 600
4 MB and 10 minutes are sensible defaults for modern apps. For Laravel with deep vendor trees, 16 MB is reasonable. The TTL of 10 minutes balances cache freshness against churn — in production, the codebase does not change between deploys, so longer TTL is fine.
Restart PHP-FPM cleanly:
whmapi1 restart_service service=apache_php_fpm
Re-check with realpath_cache_size() an hour later under real load. It should be high but not at the limit; if it hits the limit, raise again.
For per-account tuning when one customer has a much heavier app than the rest, set in .user.ini:
realpath_cache_size = 16M
realpath_cache_ttl = 600
The effect is small per request — 5-15% reduction in syscall overhead — but compounds across the whole host’s request load. On a busy box, this can mean a measurable drop in %sy (system CPU) in top. Stack Harbor tunes PHP defaults per host as part of cPanel server management.