WordPress returns 503 all day on shared hosting: check OPcache first
The first finding took ten minutes. It had been costing the store most of every business day.
The symptom
A software download store with about 30 million unique visitors a month was returning HTTP 503 for most of every business day. It ran WordPress with Easy Digital Downloads on shared cPanel hosting, with LiteSpeed and PHP 8.3. From 08:00 onward the account sat at its CloudLinux CPU ceiling, 100/100, and the host counted between 100 and 183 CPU faults an hour.
The owner had already paid for a resource upgrade. It raised the disk and MySQL quotas and left the CPU limit where it was, so nothing changed.
What was wrong
OPcache was not loaded at all for the web server. PHP was reading, parsing and compiling WordPress, the theme and every plugin from source on every single request. On a site with that much traffic, most of the CPU budget went to compiling the same files again and again.
Nobody had noticed because nothing was broken. The site worked, slowly, until traffic arrived. A caching plugin was installed and looked healthy. The page cache was fine. The layer under it was missing.
How to check yours in two minutes
Do not check from the terminal. The command line and the web server often load different PHP configurations, so php -m can list OPcache while the site runs without it. Ask the web server itself. Put this in a file such as opcache-check.php in the site root, open it in a browser, then delete it:
<?php
if ( ! function_exists( 'opcache_get_status' ) ) {
exit( 'OPcache is NOT loaded for the web server.' );
}
$status = opcache_get_status( false );
if ( ! $status || empty( $status['opcache_enabled'] ) ) {
exit( 'OPcache is loaded but disabled.' );
}
printf(
'OPcache is on. Cached scripts: %d. Hit rate: %.1f%%. Memory used: %.0f MB.',
$status['opcache_statistics']['num_cached_scripts'],
$status['opcache_statistics']['opcache_hit_rate'],
$status['memory_usage']['used_memory'] / 1048576
);
Three answers are possible. "Not loaded" is the case above. "Loaded but disabled" means the extension is there and opcache.enable is off. "On" with a low hit rate or a full cache means it is undersized.
How to turn it on
- cPanel with CloudLinux: open Select PHP Version, choose the PHP version the site uses, and tick
opcachein the extension list. That is where it was switched off on this store. - cPanel without the selector: the extension is managed by the host. Ask support to enable OPcache for your PHP version.
- Your own server: install the OPcache package for your PHP version and restart PHP.
Then run the check again. On a WordPress site with many plugins, look at two settings: opcache.memory_consumption, which should leave free memory after the site has warmed up, and opcache.max_accelerated_files, which has to be larger than the number of PHP files the site loads. The default of 10,000 is easy to exceed with a large plugin set.
What happened next
Account CPU went from a pinned 100/100 to about 15/100 within minutes of enabling it. The sustained 503s stopped the same day. No code changed, no plugin was removed and the site stayed on the same host.
What OPcache did not fix
It removed the constant load. It did not remove the bursts. This store had two more problems that a compiler cache cannot touch: search requests that each ran for about twenty seconds, and a plugin that sent an uncached request on every page view. Those are in the second article, Slow search and admin-ajax: the requests a page cache never sees.
The order I check things in now
- Is OPcache loaded for the web server, and is it big enough?
- Which URLs take the most requests in the access log, and which of them can never be cached?
- Is there an object cache, and is it actually connected?
- Only then: plugins, queries and theme code.
The cheap checks come first because they are cheap. On this site the first one was the answer to most of the problem. The full case, with every number, is on performance and infrastructure.
// services/
If this is close to what you need
Tell me what you are trying to build or fix, what already exists, and what a good outcome looks like. I reply within two business days, and I will tell you honestly whether I am the right person.
- Technical consultingA second pair of eyes, and a written answer
- Fractional CTOPart-time technical leadership for a small team
- WordPress and WooCommercePlugins that survive updates and get extended
- Performance and infrastructureSlow, expensive or unstable, traced to the cause
- Integrations and automationSystems that were never meant to talk
- ApplicationsWeb apps, macOS utilities and browser extensions
- Design to working WordPressA finished design, rebuilt natively in Elementor