Case Study

A full PHP cache was slowing 47 WordPress sites

Overnight, a customer’s main WordPress homepages went from well under a second to 1.5 to 1.7 seconds. CPU, memory and disk all looked healthy. The PHP code cache was full and frozen with other sites’ code, so the sites that mattered most were compiled from scratch on every request.

October 2026  ·  3 min read

SECTOR

Multi-site web business, managed hosting

SCALE

47 websites on one cPanel server, 41 PHP-FPM pools

PLATFORM

AlmaLinux 9, cPanel/WHM, Apache, PHP 8.4 and 8.2 FPM, MariaDB

ENGAGEMENT

Performance incident, managed support

99.4%

PHP 8.4 cache hit rate a day later, up from 66%

0.4 s

Priority homepages from the server, down from 1.1 to 1.5 s

47 of 47

Sites returning the same responses after every change

Environment

PHP 8.4 OPcache contents before and after the fixBefore: a 512 MB cache, completely full, holding code from 8 sites and none of the 3 priority sites, hit rate 66 percent. After: a 2,048 MB cache with 1,182 MB used, code from 15 sites including all 3 priority sites, hit rate 89 percent five minutes after reload and 99.4 percent a day later.What the PHP 8.4 code cache was holdingBoth bars drawn to the same scaleBEFORE512 of 512 MB: FULL8 sites cached, chosen by arrival orderPriority sites: 0 of 8 key files · hit rate 66%AFTER1,182 of 2,048 MB used866 MB freenot full15 sites cached, priority sites 8 of 8 · hit rate 89% after 5 minutes, 99.4% a day laterA full OPcache does not make room. It keeps whatever arrived first until PHP reloads.

Scroll the diagram sideways to see all of it →

Same server, same sites. Before the fix the cache had no room left and the customer’s busiest sites were not in it at all. After, every site fits with room to spare.

The problem

Slow pages on a server that looked idle. The customer reported their main homepages at 1.5 to 1.7 seconds, against 0.6 to 0.85 seconds the morning before, the first morning after the PHP 8.4 cache was raised from 384 to 512 MB. Yet CPU use was lower than the day before, load sat between 0.5 and 1.5, disk wait was about 1 ms and nothing had run out of memory. Measured on the server itself, a static file came back in 16 to 26 ms while the homepages took 1.1 to 1.5 seconds, so the time was being spent inside PHP.

Investigation

Look at what is in the cache, not how big it is. We placed a small read-only probe in a site for a few seconds to read OPcache’s own status, then removed it. The 512 MB cache was 100% used with 0% wasted, cache_full=true, 16,834 scripts and a 66% hit rate. Only 8 sites had code in it. The three sites the customer cared about most had 0 of their 8 key WordPress files cached.

A bigger cache that is full is no better than a small one. What matters is whether it has room left.

Root cause

A full cache freezes instead of making room. OPcache does not evict old code to make space. It only resets itself when its wasted memory passes opcache.max_wasted_percentage, and with 0% wasted that never happened. Each PHP reload started a new race to fill it, and there had been 5 reloads in about 24 hours. A fully cached WordPress site took 25 to 90 MB, so 35 sites on PHP 8.4 needed roughly 1.5 to 2.5 GB. A first interim fix (768 MB plus warming the priority sites) brought them to 0.34 to 0.42 s, until an automatic control-panel restart at 04:07 reloaded PHP and they were back above 1.2 s by morning. Warming the cache could not fix a cache that was too small.

At a glance

Challenge

Main homepages slowed from under 0.85 s to 1.5 to 1.7 s, with CPU, memory and disk all looking healthy.

Approach

Ruled out the server, proved the time was in PHP, then read OPcache from inside: full, frozen, priority sites not cached.

Result

Cache sized for every site: 99.4% hit rate, priority homepages about 0.4 s, all 47 sites unchanged.

The fix

  1. Size the cache for the whole server: memory raised from 8 to 16 GB, then PHP 8.4 OPcache from 768 to 2,048 MB with room for 130,000 files, and PHP 8.2 from 256 to 512 MB
  2. Give the database room too: the InnoDB buffer pool went from 128 MB to 1 GB, after 661,720 temporary tables had gone to disk since boot
  3. Change safely: settings backed up with checksums, php-fpm -t before every reload, the priority sites warmed straight after, and all 47 sites checked against their previous responses
  4. Prove it from inside: the same probe confirmed cache_full=false and every priority site cached, and a repeatable 24-hour report script now tracks cache, memory and response times

Outcome

Every site fits, with room to spare. Five minutes after the change the PHP 8.4 cache held 39,005 scripts from 15 sites in 1,182 of 2,048 MB, with an 89% hit rate. A day later it was at 99.4%. The priority homepages answered in 0.36 to 0.42 seconds from the server, and all 47 sites returned exactly the same responses as before. The next night’s kernel security reboot came back cleanly, with the database shut down first and no crash recovery. We also raised the Apache and per-site PHP worker limits for the busiest sites; their effect on the automatic restarts had not yet been measured when this was written. The before and after timings were taken on different days, both from the server.

More case studies

WordPress Performance

1.8 s page load, down from 12 s

NGINX Limits Ignored Under SELinux

65,000 open files per worker, verified live

ionCube and OPcache Stuck in a Loop

≈300 s → 2.2 s homepage render after one setting

Is your PHP cache big enough for every site?

We check what is actually cached, size it for the whole server, and prove the result with measurements.