5

I've heard great things about HHVM, so I've setup a copy of WordPress blog (on another domain) with Nginx (with the Pagespeed module) and HHVM. Right now the benefits are obvious: on the same config, load times are between two and three times faster.

I'm trying to speed up things a little bit, and I've also installed Memcached and Batcache. I've installed the memcached package, copied object-cache.php (Pastebin) onto the root folder of the WordPress blog, and after that I've installed the Batcache plugin and copied the advanced-cache.php (Pastebin) file onto the wp-content folder. Also, I've included the line

define('WP_CACHE', true);

in the wp-config.php file. It seems it doesn't work, though. If I quickly reload the page several times Batcache should show the cached page, but it doesn't. It's easy to check that by reloading (Cmd+R on Chrome on OS X) the page several times and then viewing the page's code. Under the <head> section I should see some batcache stats, but they aren't there.

I wonder if someone could give me some hint on this.

On a side note, I don't know if I could add some other component in order to help the performance be even better. I'm thing about Varnish, but I'm not sure if it's just useless and it's just another way to the same I'm currently doing. Any other component there? (I'll test CDN for images, minifying js, etc and some other tricks as well, but I'm talking from the server perspective).

  • Are you sure memcached is running, what happens if you dump out the global $batcache, have you altered the settings in advanced-cache.php? Are you using a multi-server environment, and why are you optimizing so much (need, learning, ?) – Wyck Aug 27 '14 at 15:02
  • Memcached is indeed running (I can see it both in top/htop or with a quick telnet localhost 11211), and the config file has not been altered (it's on the Pastebin link I included. How do I "dump the global $batcache"? Also, its a single server, and I'm trying to get the site as fast as possible more for my own pleasure and to learn a little bit about web performance. – javipas Aug 29 '14 at 8:36
  • To dump it out just do something like var_dump($batcache);, memecached is fairly pointless on a single server, it's for distributed servers, look into using the default PHP opcode cache, php.net/manual/en/intro.opcache.php. The golden rule with optimization is only do it if you need to (it is fun to learn though). – Wyck Aug 29 '14 at 15:31
  • Thanks for pointing out the Memcached problem with single servers (I thought that it was requirement to get batcache working). I wonder though if using OCache or even something popular for WordPress such APC is redundant now that I'm using HHVM. Aren't HHVM and APC almost redundant? – javipas Aug 30 '14 at 18:47
  • HHVM is a compiler and opcode caching is a caching system made for "regular" PHP, but they do have some similarities as far as caching is concerned so it would be redundant ( I don't think it would even work) unless your using memcached for distribution. I am not sure if memcached will work with HHVM, though it should. This discussion is better suited to chat chat.stackexchange.com/rooms/6/the-loop – Wyck Aug 31 '14 at 16:56
1

I guess the answer is that HHVM does not work with typical opcode caching, the compiler is not the same as "regular" PHP's. HHVM has it's own opcode caching that as far as I know does not integrate with APC or Zend's OPcache, it does it's own thing. In other words, it would be redundant.

You can read about it in detail here: http://hhvm.com/blog/4061/go-faster (comparison with APC).

You can however use HHVM's caching with memcached ( at least I think you can) there are several issues and patches on HHVM's github about this, https://github.com/facebook/hhvm

I have never used HHVM but there must be a way to test or debug the cache, that is probbaly your best route, plugins that take advantage of "regular" PHP like batcache will not show anything.

To test if it's working turn off HHVM caching ( I think the settings are found under runtime options) and test the site with it off/on or with different cache settings.

Another option is to just define('WP_CACHE', true) in your wp-config.php file, and you can benchmark HHVM with this off/on and see if it has any effect.

You can see here a compatible list of PHP extensions that work with HHVM: https://github.com/facebook/hhvm/tree/master/hphp/runtime/ext

  • Good explanation, Wyck, that answers one of my main doubts, but again, I think batcache should be running and it's not. I don't know how to check it (dunno how to test that code you gave previously), and I would also like to know what happens with Varnish. Is it too redundant? – javipas Aug 31 '14 at 20:45
  • Varnish would be something to use only if you need it, for lack of a better term is can act as a layer in front of your server. As for batcache + HHVM with memcached , in thoery you should be able to test if this is working but most likely you would need to look into it yourself, its somewhat advanced. – Wyck Aug 31 '14 at 21:16
  • Thx Wyck, I'll try to see what happens, maybe I'll use some caching plugin instead and see what happens. – javipas Sep 1 '14 at 6:32
  • According to a Mark Jaquith comment: "HHVM supports APC user cache and Memcache, so if you drop in the object caching backend for one of those (and for Memcache, configure it and have it running), Batcache should just work." – icc97 May 7 '15 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.