The (in)Complete Guide to WordPress Performance
Welcome to our WordPress performance guide
This incomplete guide to WordPress performance will grow organically over the coming weeks in response to your suggestions. I had been hoping to complete it before releasing, but I think getting it out there in incomplete form will help me complete it quicker.
Fast Websites Matter
Fast websites make more money. When I optimise websites for clients, conversions go up, pages viewed per user go up, customer lifetime value increases and even inbound traffic from SEO gains a boost.
The fact is, caching cannot solve every WordPress performance issue. Admin pages cannot be cached, pages for logged in users (your most profitable users!) cannot be cached, and when GoogleBot indexes your site, it does not behave like a normal user – instead of accessing only your most popular pages like your users do, it accesses EVERY page. That means the pages are likely not cached and GoogleBot will leave with a bad impression of the speed your site runs.
On large sites, you cannot cache everything and if you could, you still could not prime the cache for every page in a timely manner.
That means the underlying performance really matters. Your /shop/ page having a 0.2s database time rather than 10s database time really matters. Your wp-admin pages loading in 1 second rather than 20 seconds really matters. GoogleBot changing its opinion of your site to a FAST site really, really matters.
In the guide below, I’ve tried to include the free DIY approach for each performance area where possible as well as the BEST premium option and our own option if we have one.
I’ll be on our hullo chat system most days – come talk to me about performance.
Choosing a top quality host and a good hosting stack are the the first and most important part of improving your WordPress performance.
There are a large number of hosts to choose from – you should look out for hosts that use solid state disks (SSD) and which allow you to choose your operating system (e.g. Ubuntu 16.04).
We recommend Digital Ocean if you need a good SSD-based VPS.
WordPress Hosting Stack
Once you have a good host, you need a good stack. The stack is the underlying software upon which WordPress runs. It includes things like the PHP version, the MySQL version and the web-server version.
You should demand PHP 7 instead of PHP 5.6, either MariaDB or PerconaDB instead of MySQL 5.7 or even worse MySQL 5.6 or 5.5. You should also demand Nginx instead of Apache, fail2ban to protect your site at the top level and some kind of object cache – either Redis or Memcached will work well.
If you are uncertain which versions of these things you have with your current host, you can install the WP-ServerInfo plugin to find out.
Once you have these items installed, you should ensure they are configured correctly for optimal performance. See our DIY guides below for configuration ideas.
The Rocket Stack is our high-performance WordPress stack. It has all the tools you need, pre-configured, to run an ultra-high performance WordPress website.
We can install the Rocket Stack on any VPS provided it has a fresh copy of Ubuntu 16.04 installed and you have added our public SSH key to the server.
Rocket Stack Contents
Your server will be set up and configured with:
- Nginx – faster web engine than Apache
- Varnish – front-end caching engine configured for WordPress
- MariaDB – 100% compatible, faster than MySQL
- PHP7 – about 3 times faster than PHP 5.6
- fail2ban – protects your site from botnets, reducing load
- Redis – used for ultra-fast object caching
- Free SSL for life using Letsencrypt
Technical DIY Guides
If you want to install a new stack yourself, you can follow our guides below:
- Guide to installing the Rocket Stack (coming soon)
- Guide to installing the Mercury Stack
- Guide to intalling a fast and easy stack using Server Pilot
We recommend Digital Ocean for your hosting – droplets commissioned in 60 seconds, full VPS capability, many locations throughout the world and a snapshot function which lets you clone your servers with no downtime. Take snapshots before major changes, or clone your high performance rigs for fresh websites.
Digital Ocean use SSD solid state disks which are 20 times faster than HDD hard disks and you get useful server admin functionality from their website – like access the console, reboot, check CPU/DISK usage and more.
You can install our ultra-fast Rocket Stack on your Digital Ocean droplet, or you can DIY build your own stack using one of our DIY guides.
Or an even simpler approach – when you are creating your droplet, Digital Ocean give you the option to create it from a WordPress image – this will get you a basic WordPress stack (not as fast as our Rocket Stack), but if you’re coming from a shared hosting environment or a non-SSD environment you’ll still see a significant speed boost. Good if you’re on a budget.
You get $10 credit which is enough for their smallest droplet for 2 months through the affiliate link below.
Scaling refers to your fast website remaining fast when you have huge traffic spikes and also refers to your fast website remaining fast when you have millions of products, posts or pages.
Traffic spikes are actually fairly trivial to deal with as they tend to hit one or two of your pages. This means that you can take advantage of things like page-caching, image-caching, static-file-caching and CDN caching to serve up that content quickly to all these visitors without them having to hit your WordPress website at all.
To ensure you survive traffic spikes, get yourself a decent CDN and a decent page-caching plugin that supports Varnish. Configured correctly, your CDN and Varnish will ensure these traffic spikes get served without even running any PHP code to serve up your content.
Scaling in Size
If you are scaling in size – millions of products, posts, pages or users – the most important point to note is to avoid table scans. Table scans occur when poorly written code forces MySQL to read every product, post or user in order to generate your page. If this is occurring on your site, you will not be able to scale in size without spending inordinate amounts of money on hosting.
In order to solve growth-scaling, we’ve developed a plugin to optimise your website and ensure table scans do not occur.
It includes specific code and widgets for WooCommerce to ensure you can scale your stores to millions of products.
It includes indexes and sql alterations to ensure your back-end admin operates faster and scales.
It also includes significant speed and accuracy improvements for free-text search.
Scalability Pro doesn’t include page-caching, so in addition to it you should choose one of W3 Total Cache, WP Super Cache and WP Rocket.
Far and away this is the best caching plugin available but you do have to pay for it. It’s not costly though, and their feature-set far outweighs that of W3 Total Cache and WP Super Cache.
W3 Total Cache
Written by the CTO of Mashable – it’s my favourite, but it can be a little tricky sometimes.
Use it to enable page-caching using disk and object-caching using Redis.
Do not enable the minification features as I’ve found them to be buggy. If you want minification, use Cloudflare minification features.
WP Super Cache
For some reason, when this plugin is activated it has some broken settings. Visit the settings page immediately and ensure you are not caching pages for admin users.
Importing To Wordpress
Importing lots of products to WordPress can be painful. I hear stories of people managing to only import 5000 products per day.
1 million+ products imported per day is easily achievable.
Why is importing Slow?
Importing to WordPress is slow for really three key reasons:
- Items can only be inserted one at a time
- Table scans are happening
- Imported images need to be resized and saved
If you could simply import directly to the database, you could very easily achieve billions of items inserted in a day. WP All Import do provide an option to disable the do_action commands which can give you a little bit of a boost, but it’s still importing one at a time through PHP.
To avoid the table scans, use Scalability Pro – it has specific indexes for queries performed by various import plugins.
One technique to avoid importing images and speed up imports is to use our External Images plugin. This fools WordPress into thinking the image is stored locally when it’s in fact elsewhere.
If you are not an affiliate marketer, you can still take advantage of this plugin – get your images stored somewhere – e.g. Amazon S3 – and ensure your import file includes the URL to that image.
Technical DIY Guides
If you want to import vast quantities of data, we’re here to help:
Streets ahead of the competition, WP All Import lets you import posts/products from anywhere – CSV, JSON, XML – you can even give it a URL to read the data from, meaning you can point it any RESTful API.
The official WooCommerce CSV importer on the other hand fails dreafully – it forces you to create CSV files in its format whereas WP All Import doesn’t care about the format of your file. It will interpret it and let you drag and drop the fields from your file to your fields on your post/product/page.
Datafeedr is by FAR the easiest way to import affiliated products into your site. If you are using WooCommerce, you should use the Datafeedr API rather than the Datafeedr Factory.
Datafeedr are connected to pretty much every affiliate data feed in the world, so it’s a fantastic way of populating your niche affiliate store – you don’t need to bother with datafeeds at all – just search for the products you wish to add and either add them one by one or create search filters to add en-masse.
Scraping content to load into your site has never been easier. You can use any of the third-party services below to build an index for your scrape and you’ll end up with a URL where that scraped data is available.
Provide that URL to WP All Import and you can import data scraped from publicly accessible site in the world.
Theme & Plugin Performance
If you have covered all other bases – you have good hosting, you have Scalability Pro, you’re maybe using our External Images plugin too (for affiliates mostly) – if you have these covered, and you still have poor performance at scale, that leaves plugin and theme performance.
Here we guide you through identifying which plugins are causing you scalability and performance issues, and how to choose a good theme.
If a client of mine has a good hosting stack and Scalability Pro and they are still experiencing slow speed, it’s almost always another plugin I haven’t yet optimised.
To identify slow performing plugins, the process I follow is this:
- Install Query Monitor plugin – this gives me a page-speed in seconds on my admin bar.
- Click the page-speed – see if there are any slow database queries – if so, remove the related plugin or optimise it
- Scroll to the bottom and find how many SQL queries are performed by each plugin – if one has a huge amount, investigate and remove or optimise the plugin
If you don’t feel like using Query Monitor, the quickest way to find which plugins are causing scalability issues is to deactivate 5 plugins at a time and check the page again for speed.
If it’s the same speed, re-activate those 5 and de-activate the next 5.
Once you’ve get the page loading quickly, reactivate each of those plugins one-by-one and check page speed each time until you identify the culprit.
Please do let me know if you’ve found any crap plugins that kill your performance so I can add them to my plugin blacklist.
We highly recommend Themify themes. They are fast, highly configurable and come with a far better visual drag and drop interface than the awful Visual Composer we keep seeing everywhere.
If you suspect you have a slow theme, you can test this by switching your theme to the default WordPress 2017 theme. If you are worried, take a backup before hand, but switching your theme out and then back will be seamless (it’ll look ugly in the default theme but everything will go back to normal when you reactive your original theme).
Your best port of call if your theme is a problem is either to get the developers of the plugin to fix performance or change themes.
You can also find some great tips at the following resources: