Memcached compatibility

I have a couple of Wordpress sites running on a Sympl VM.

One of the sites has a page that makes a large number of MySQL queries when it loads, maxing out the CPU. I’d like to try to improve this using memcached.

Two questions:

  1. Is memcached compatible with Sympl?
  2. Is installing it just a case of “apt-get install memcached” or are there other steps involved with setting it up?

Hi Tim,

  1. Is memcached compatible with Sympl?

Yes, it should work fine with Sympl.

  1. Is installing it just a case of “apt-get install memcached” or are there other steps involved with setting it up?

It’s usually just a case of installing it - it’ll only be accessible from localhost by default, then you just need to configure WordPress.

As an alternative, you might want to think about APCu as it’s a bit simpler:

  • if you’re running Sympl 12 then echo '7.4' > /srv/ to set the PHP version to the current ‘most compatible’ version for WordPress, then echo 'apcu' > /srv/ to add it as wanted for the site and finally run sudo sympl-php-configure and it’ll set it up and manage it for you. If you want to separate the sites so they can’t see each other, then put a unique string in /srv/ on each site.
  • if you’re running Sympl 10 or 11, then just apt install php-apcu - there’s not an easy way to isolate them in this setup, but with only a couple of sites you should be fine.

Great, thanks. I’m on Sympl 12. Do I need to install apcu first or is it available by default?

It’s not installed by default (only a few common modules are) so you should just be able to add it to php-modules and choose a PHP version and let Sympl do the rest.

Ok thanks. I’ve done the above - how do I tell if apcu is running?

I have tried php -i | grep apcu and php -r "var_dump(function_exists('apcu_enabled') && apcu_enabled());" which don’t show it running.

One other thing - I have a file named 7.4 in /srv/ but your instructions suggest that php should be a file, not a directory. It looks like my site is running PHP 8.2.17 so something isn’t getting picked up. Should I delete the php directory and replace with a file containing 7.4?

You’d need to look at either the command-line PHP, but with the right version - so if you’re running PHP 7.4, then you want php7.4 -i | grep -i apcu (adding a -i to the grep to make it case-insensitive).

Yes, it should be the text 7.4 in the the file /srv/ rather than anything in a directory. If you fix that and run sudo sympl-php-configure, it should swap things over and install missing items.

(Note there’s a very cool new feature about to hit testing, which will automatically use the relevant version of PHP based on what directory you’re in, and what you have set in config/php!)

Ok thanks - I’ve sorted the file and have run sympl-php-configure and now get:

root@vm:~# php7.4 -i | grep -i apcu
APCu Support => Disabled
APCu Debugging => Disabled

Does that mean apcu is disabled? Or just disabled on CLI?

It means it’s installed but it’s disabled on the CLI.

If you temporarily create a phpinfo file, and access via the website, you should see it enabled there.

Alternatively, you can probably just add APCu Manager – WordPress plugin | to the site in question and see what it reports!

Great, thankyou - that looks like it is running fine. One of our least efficient pages is down from a 15s page load time to around 3. Thanks for the help!