I’ve been developing a WooCommerce store that currently has been in production for several years. Over the time the store grew and currently contains some 200 products, 3.5k orders and over 40 plugins. Over the time we have always been struggling with the TTFB which we hoped would be solved by migrating to a more powerful server. We finally found the money to move to a new host and unfortunately the expected improvement didn’t show up.
The problems are most apparent in the admin panel, since we use caching on frontend, so the average user doesn’t experience that much problems but once the customers start to add items to their cart and go through the checkout, the performace problems hit the them too. I am talking about TTFB of around 5s, sometimes even more which together with the other rendering stuff often leads to page loads that take 8+ seconds easily.
I already tried several things – cleaning the database from ghost entries, optimizing the database tables, installing different profiler and query monitor plugins but it yielded basically no results.
When I deactivate all the Woocommerce & WordPress plugins that we are using, the TTFB drops to about 1.2-1.5s (which I still don’t find to be really satisfying). When slowly activating one extension after another, I am observing quite steady performance deterioration and end up with the TTFB of about 5s+.
I also installed the Query Monitor and I can see that basically every page load (no matter whether it is frontend or backend) consumes more than 200MB of RAM and queries the database 500-1000 times. Interestingly the DB queries usually take around 0,5s which makes me thing the database isn’t the issue here.
Honestly, I am running out of ideas here and you can probably imagine the client is not happy that we are stuck with this horrible performance. What I would like to ask you all here about your experience. I am not even sure at this point whether this could be kinda normal behaviour with that many plugins. If so, is there anything we can do except for hardcoding stuff and eliminating as many plugins as possible? And if not, would you have any idea where to look for the problems and what to do?
Thanks in advance for any opinion you may have!
2
Answers
The problem you’re facing is WordPress itself, more specifically the architecture and how PHP and the WordPress Plugin system is so decoupled. What is happening, at best (not reality) is 1x database query per ‘thing’, but in reality it’s many database queries per ‘thing’.
It doesn’t really matter what the figure is. PHP is a technology that is simply not optimised for performant database querying in high throughput environments. Added to that, WordPress is designed for flexibility, not performance, so the Plugin eco space ultimately leads to more database requests for every additional plugin that is installed.
When you look at any kind of performance, one you’ve taken the easy route of boosting the VM/Server, the next route is looking at the number of opening/closing database connections, that is generally the root cause of a lot of problems – assuming you haven’t got crappy SQL queries behind the scenes in some dodgy Plugin taking a long time to run due to poorly structured queries.
PHP runs on PDO. It doesn’t have the concept of Database Connection Pooling. This is why WordPress, more specifically, PHP has problems with performance on scale.
All that being said. "3.5k Order over Several Years" is hardly what I would call High Performance.
Moving to a "New Host" or "New Server", doesn’t really mean anything. What are you ACTUALLY paying for? vCPUs? RAM? Network Bandwidth? IF you don’t know this, then you have probably just moved to yet another crappy web hosting provider with good marketing material.
Ultimately to get this stuff to work for you, it sounds like you are at the inflection point when you probably want to consider hosting your environment on a dedicated machine in some way (every company markets this as something different, but what I’m talking about is X vCPU / CPU, Y RAM etc. aka. Something that is 100% ‘yours’)
This is quite an old guide but still the principles are fairly relevant on what all this means and what you can do about it – https://www.contradodigital.com/resources/really-simple-guide-to-web-servers/
What can you do?
Activate a persistent object cache. This should cut down a lot of the database hammering you see in Query Monitor.
Fix the indexing on your database tables to adapt better to modern database tech and WooCommerce’s workload. @RickJames and I got sick of answering this question over and over here, so we created this plugin to address the problem.
If you can, purge out old orders from your system.