I have a very odd problem: 2 seperate wordpress sites running on 1 apache server and always one site runs slow and the other fast.
The peculiar thing is that the last site to receive wordpress updates is always the faster site.
If I install a theme (without activating) on one site then that will be the faster site. Then if I install a new theme on the other then that will now be faster.
Using the query monitor plugin I can see that the slower site always has much higher peak memory use of around 150mb per page and the faster site is always much lower around memory use 50mb.
My install is debian 12, apache2, mariadb, php8.1
Both sites use the same theme and similar plugins.
Both sites work well other than this.
Cached pages are served at the same speed with no issues.
Can anyone suggest what might cause this ?
2
Answers
I’ve found the reason. Opcache memory was full and so was only working for 1 site at a time.
Using the plugin WP OPcache I can see what opcache is doing.
Then for my server I edit the opcache config file which in my case is
I added these settings:
restart php which in my case is
and both sites now work the same.
I’m glad I’m not the only one who runs into mysterious problems like this 🙂 I think this might have to do with how you are measuring the speed of the site.
I would suggest really measuring the performance of both sites. Use the simple code provided here: Simplest way to profile a PHP script Create a page template and add $then = microtime(); before get_header() and $now = microtime();
echo sprintf("Elapsed: %f", $now-$then); after get_footer(). See how the output compares between the different sites.
I bet you’ll find the performance is the same, and doesn’t change when your other method of measuring performance tells you one is "faster".