How to Identify and Fix Scalability Issues on your WordPress Website
- Installing Xdebug remotely to debug WordPress and gather profile traces - November 23, 2022
- Speeding up WooCommerce 7 (wp-admin and imports) - November 4, 2022
- More speed boosts for wp-admin and imports with Scalability Pro upgrade - October 12, 2022
Over the 2 years of running WP Intense, I’ve had many questions from clients asking to review the performance of their website. In this article I’ll cover the most common issues and the easiest solutions to solve your performance and scalability.
Table of Contents
Uncached versus Cached Performance and TTFB
Firstly, it’s important to understand why uncached performance matters.
The most common solution to scalability issues in any platform is to cache everything. Problems arise when it’s impossible to cache everything. This commonly happens when you have a lot of products and/or posts, and you have a lot of filters. It’s impossible to cache all the varieties of filters, so it’s important that your uncached speed is not killing your server.
When an uncached request consumes all your server’s CPU and disk for 10 – 40 seconds, it doesn’t only affect this one user – it affects everyone. If you’ve ever experienced your PC maxing out due to some large batch job you’re running, you’ll know this kind of pain already.
By fixing uncached performance, you make it far easier for your server to generate cached pages for immediate delivery to future users.
The first, and most obvious, issue is your hosting. If you’re on a shared server, you should really fix this before anything else. With the advent of the likes of Digital Ocean with $10 per month droplets, there’s really no good reason to be on shared hosting any more.
Firstly, shared hosting typically limits your MySQL connection counts. They might limit you to 10 connections, or if you’re lucky, you might get 50 connections. Regardless, you want NO limit.
Secondly, you have no CPU or DISK resource to yourself. That means two things – firstly, your performance is going to slow down intermittently based on what other users are doing on the server you’re sharing. Secondly, it means it’s incredibly difficult to identify performance bottlenecks when you can’t tell if it’s an issue with the plugins you have installed, or whether it’s just that another customer is abusing your server with a massive import job that’s consuming CPU and disk resource.
For good hosting, I recommend any of:
- Digital Ocean – if you have some technical capabilities, this is the cheapest option with the best bang for your buck. There are a variety of stacks you can install, and Digital Ocean gives you total control over your WordPress environment.
- Cloudways – these guys provide a managed service on the Digital Ocean environment. If you need managed support, this is the second most cost-effective method of getting good hosting.
- WP Engine – if you want real hand-holding, and don’t want to think about your stack or WordPress technical environment at all, WP Engine are a solid choice
Good Server Stack
If you’re still using PHP 5 or MySQL, you have a poor server stack. Top of the range looks something like this – you can speak to your current hosts and ask them if they can provide it:
- Nginx instead of Apache
- Redis or Memcached instead of no memory-based caching engine (or instead of disk caching)
- PerconaDB or MariaDB instead of MySQL
- Varnish or Nginx fast cache instead of no micro-caching or short-term page-caching solution
- SSD instead of HDD
- PHP 7 instead of PHP 5
- Fail2ban – this beats WordFence on performance and security, no question. It solves security at the firewall level meaning any bots attacking your site consume ZERO resources on your server
- Letsencrypt SSL – Google cares about HTTPS these days and is starting to warn users that non-HTTPS sites are insecure. If you have users logging in, you MUST use HTTPS. Letsencrypt gives you free SSL certificates for life.
Too Many Queries
If you’ve fixed your hosting, or if you’ve skipped ahead to this section, one of the two most common WordPress-based scalability issues is plugins that have been installed which are causing far too many queries per page.
To identify if this is an issue you are suffering from, you should install Query Monitor by John Blackbourn. Once installed, visit your slowest page whilst logged in and look at the Query Monitor admin bar. For example:
There are 4 numbers that Query Monitor shows.
- Total page load time (in this case, it’s TTFB or Time to First Byte). In the example above, it’s showing 2.92 seconds TTFB which is quite slow (although it IS on a 850,000 product site)
- Total page size, in KB. In the example above, it’s showing 10MB page size which is quite large.
- Total MySQL time. In the example above, this is 2.36 seconds which is a lot, but it also tells us that the amount of time spent in PHP is 2.92 – 2.36 which is 560ms PHP execution time.
- Total number of MySQL queries executed on the page. In the example above, 54Q or 54 MySQL queries is very low.
So – if you install the Query Monitor and you see that you have a LARGE number of Q, for example over 100Q, then you have a plugin problem and you need to find the culprit.
Thankfully, Query Monitor provides an option to view queries by component. See this screenshot:
After you’ve clicked “Queries By Component”, Query Monitor will scroll down the page to something like this:
In the example above, there are no real issues. Fewer than 100 queries is totally fine for a WordPress page. But if you have a lot of queries, you’ll typically find 1 or 2 plugins at the top of this little table which identifies where all your performance is disappearing to.
If too many queries is the issue you’re experiencing, you’ll find that counter 1 above is showing a large time and counter 3 is showing a low time. This is because, when there are too many queries, the time to generate the page is bottlenecked by the speed of your PHP processor. More CPUs will help, as will PHP 7 instead of PHP 5 as it’s about 3 times faster at executing PHP code.
In any case, the most logical next step is to eliminate the plugin culprits.
On the other hand, if you have a low number of Q (fewer than 100) but the MySQL execution time is large, then the likeliest situation is that your MySQL database (or PerconaDB or MariaDB if you followed the first steps) is performing table scans. Table scans are the enemy of scalability. Basically, they typically mean that every item in the table is being read into RAM. This has multiple problems. Firstly, it causes all your MySQL cache to be wiped. Secondly, it causes your DISK to thrash whilst fetching all this data.
To solve this, you need to eliminate the table scans. This is specifically why I built Scalability Pro. If you have Slow Queries, Scalability Pro will solve your uncached WordPress performance.
Fix your hosting, then identify which type of scalability problem you have. If you have too many queries, replace the problem plugin(s) with superior plugins. If you have slow queries coming from your plugins, get Scalability Pro to solve your slow performance.
If, for some reason, Scalability Pro does not solve your slow queries, rest assured that my mission is to fix EVERY slow query that exists, working from the biggest plugin culprits downwards.
I’m looking forward to any questions or comments.
September 11, 2017 @ 8:53 pm
Thanks for sharing.
September 12, 2017 @ 8:04 pm
Hi Dave – I am really keen to get the fastest hosting possible for my woocommerce site. I contacted WP Engine Sales to ask them some questions and I was really surprised that they said in order to host my site I would need a plan which starts at 600USD per month. Please see below for our email conversation thread.
It would be great to have your thoughts on this.
Thank you for providing me with the link. I have looked through your site and I wanted to let you know that, unfortunately, the personal plan will not work for this site. Your site is a woo commerce site and the specs listed on our plans page are mostly for informational sites like blogs, magazines and company sites https://wpengine.com/plans/
Any woocommerse site would be a very resource heavy and we recommend dedicated solutions for any woo commerce site. Here is a great blog post by a 3rd party developer that explains it better http://chrislema.com/woocommerce-hosting/
And here is the link to an extensive white paper that you as a business owner will find helpfull https://wpengine.com/wp-content/uploads/2016/03/WP-EBK-ScalingWooCommerce-v06-PUB.pdf
Besides the database calls, as the blog mentions, caching will be another issue. Caching will have to be disabled in order for a customer to complete a purchase. We can do it on some pages on our shared plans but it is impossible to do on a homepage. So no purchases can be made on this page http://demo.ecocollective.co.uk/.
On a dedicated solution, we can disable caching altogether. The pricing for dedicated solutions start at $600/mo and scales up from there.
Let me know if you have any other questions or requests.
SALES DEVELOPMENT REPRESENTATIVE
Sep 11, 11:06 PM CDT
Thanks for getting back to me. Our site is currently under development and in maintenance mode but you can see a demo version – log in demo and demo – here http://demo.ecocollective.co.uk/
We are to be adding another 7000 products, currently we have around 2000, and I am concern that this, along with some additional functionality such as an API to our wholesaler will affect the site performance. I have been recommended WP Engine by a developer who specialises in making WordPress ecommerce sites faster.
I’m glad you have the staging site function.
Mariana Nasreddine (WP Engine Support)
Sep 11, 1:54 PM CDT
Thank you for contacting WP Engine. My name is Mariana. I am WP Engine solutions and sales team member. Can you share your site URL with me? It is always helpful to have a site in front of me to make sure I am offering you the best service. Also, what made you want to change from SiteGround to managed hosting with WP Engine?
We offer one-click staging with all our plans, shared and dedicated. Here is more information on this https://wpengine.com/support/staging/
Feel free to contact me if you have any other questions or requests.
SALES DEVELOPMENT REPRESENTATIVE
Sep 10, 11:34 PM CDT
New submission from the WP Engine website contact form for sales
message : Hi I\’m interested in your first level hosting at $29 per month. Please can you tell me if it is possible to create staging sites? My current hosting – siteground – provides this with one click and I find it extremely useful. Regards Juliet
wpe-form : 1
[personal details removed]
September 14, 2017 @ 2:27 pm
Hi Juliet – $600 is a LOT of money to spend! Depending on how large a store you’re talking about going for, a $40 per month Digital Ocean server will most likely be enough for you with the right stack.
You should also get our Performance Plugin pack as it’s focused on optimising WooCommerce – Scalability Pro fixes database queries, Faster Woo Widgets fixes widget/filter performance, Auto Infinite Scroll lets you remove pagination for even more speed and Super Speedy Search gives you instant free-text search.
You can see a guide to installing the Rocket Stack here:
Alternatively, we can install it for you and do your migration – create a ticket if this is of interest to you.