If you are using WooCommerce with lots of products, you’ll have noticed it slows down significantly. There is some pretty bad code inside WooCommerce which iterates through every single one of your products in PHP to build category lists – these operations take milliseconds in mysql but tens or hundreds of seconds in PHP depending on how many products you have in your store.
HHVM – Hip Hop Virtual Machine – was built by Facebook to change PHP into a compiled language rather than an interpreted language. Specifically for these terrible types of language patterns, HHVM will give you significant speed boosts. (Better would be if WooCommerce could get their code sorted out)
# installs add-apt-repository sudo apt-get install software-properties-common sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 sudo add-apt-repository 'deb http://dl.hhvm.com/ubuntu trusty main' sudo apt-get update sudo apt-get install hhvm
That’s HHVM installed, now to get it running:
hhvm --mode daemon -vServer.Type=fastcgi -vServer.Port=9000
If you’re using Nginx, all you need to do is stop the PHP5-FPM service and ensure you’re sending traffic over to port 9000.
With a client’s site – she has 105,000 products in WooCommerce – previously she was getting a response from /store/ (a page that really should be far quicker but isn’t because of the product/category counts which occur) in 185 seconds. With HHVM that same page returns in 10 seconds. Still not ideal, but at least NOW when I combine this with a caching system it’ll work for all users.
There is some additional info here about getting it set up with Nginx
Ensuring HHVM stays up and Configuring CRON
It’s new and shiny and might break easily so you should set up a cron job. With some testing, I found that you don’t need to check if it’s running – just try to run it. If it’s already running, it sorts itself out. You should also take this opportunity to switch from PHP-FPM to HHVM for your cron jobs too (if you’re using cron for your cron jobs that is)
The following two lines at the end will do it.
*/1 * * * * hhvm /var/www/insertyourwebfolderhere/wp-cron.php */1 * * * * hhvm --mode daemon -vServer.Type=fastcgi -vServer.Port=9000
Setting all of this up the easy way
If you don’t want to mess about with linux and you’d rather have someone do this for you, WP Engine are the best in the business. They have nginx set up, they have high capacity, failover based systems and they were one of the first to set WordPress up with HHVM. They’re affordable too – you can find out more about WP Engine here.
- My WordPress performance plugins and server stack have moved - July 31, 2016
- Price Comparison Pro 1.2 Released - July 5, 2016
- How to run backups on huge WordPress websites without your website being brought offline - February 4, 2016