One of the most common questions I hear a lot about WordPress and eCommerce revolves around the notion of WooCommerce and it's ability to scale. “Can you scale WooCommerce?” people ask me. And my answer is always yes.
But it's never as simple as that, right?
People want to know if you're just being nice, being hopeful, or just not experienced enough to know if WooCommerce can really handle a high amount of traffic.
For me, working with WooCommerce and customers for a few years now, scale has been a moving target. At one point, watching a store get thousands of hits an hour was a talking point around scale. Then, it was tons of concurrent orders. And finally it really was insane scale requirements, late in 2015.
To step into the topic, we first have to define some terms.
How do you define “scale?”
Scale can mean a lot of different things to different people.
Some people will talk about scale in the pageview world. How many page views per day (or hour) are happening on a WooCommerce site. The truth is, with the right kind of caching strategies, this is a metric that won't help us much when it comes to scale. Unless you can't cache any parts of your pages, pageview counts aren't a great indicator of scale.
Others will use revenue per day as a metric for scale. Unfortunately, this ends up being an apples to oranges comparison because revenues from sites that sell sandpaper at $0.40 per sheet and stores that sell backpacks for $300 each can't really be compared.
You get closer when you talk about order volume. But the problem with orders is that people can start and order and then quit you—you know, cart abandonment. And that means it won't be counted in your assessment of that metric. Because most people, when they are talking about orders, are talking about closed orders.
So what metric do I use (and recommend)? Add to cart events per hour (or minute). This puts every site on equal footing. Unfortunately, this isn't a metric that appears straight out of the WooCommerce reporting system. You'll have to do a little bit of work to capture and monitor the metric. But I think it's the best way to evaluate the behavior on a site, while also looking at the correlation with traffic and order volume.
Once you have the right metric, you can get started on measuring where you are, and determining what kinds of things you want to do to get to where you want to be. For my client back in 2015, we spent a year working with them and their site (and code) to get them to 2,000 add-to-cart events per minute.
That's what I call scale!
What areas need to scale?
One of the most common mistakes people make with their WooCommerce site is believe that after an order is complete, people will leave the site. It's a common misconception because we all like to think transactionally. So you go to the store, make your purchase and then leave.
But some people end their purchase and may stick around, browsing the store again. Only this time, they're still logged in. And that means nothing is cached. And every click and page they visit is making calls to your database.
So the first thing you need to look at—that's really simple—is to make sure that after an order is complete, you log folks off, so that they can browse the pre-cached store without causing scale issues.
Caching Strategies for category pages and menus
Because it's an eCommerce site, many developers just skip caching all-together. They don't want to worry that they may misconfigure something like Varnish. So in the end, nothing is cached, and that's another mistake. A ton of the site can still benefit directly from a caching perspective – even an aggressive one.
Much of the catalog can be cached and you only need to update things if someone makes a change to the product definition. And instead of using WooCommerce to create your category pages, you can create whatever pages you want, and eliminate more queries there. And if we're talking about caching and limiting query calls, look at your menus and see how much of them need to be dynamic.
The Postmeta table
Every order that is written to your database is putting all the order data into your postmeta table. This table gets big quickly and the query counts get large. One thing you might consider is intercepting the orders and writing them to a single, multi-column row. But if that kind of change scares you (and I totally understand why it would), you might also look at making a table change in the database that helps indexes run better. This can have an immediate impact!
The My Accounts page
I know we've often found the My Accounts page to be a place where tons of performance optimization can happen. Think about it for a second – customers are coming here to check to see stuff about their orders, but the calls are querying everything – all their historical data. And that's happening why others are trying to order stuff.
What we saw was that working on these calls and scoping them would translate into a massive reduction in performance delays – and that resulted in immediate increased scalability.
Change the query engine completely
What if you could change how the queries were running altogether? What if you could make everything faster? With a single change? That would be almost too good to be true right? Well, you're right, it's never just one thing. But rolling in ElasticSearch and having it do a lot of the querying for you could provide huge gains.
Does scaling WooCommerce require a lot of custom code?
It's not tons of custom code that is the issue. The real issue in getting your WooCommerce site to scale is experience. If you've never done it, you likely don't know how to do it. In fact, you don't even know what to look for. So while yes, you may need a little bit of code, what you likely need is some recommended resources.
Let me help you with that. I know each of these companies well and trust you in all their hands.
- Elastic Search: Zeek Interactive, 10up
- WooCommerce Sites: Zao, webdevstudios, Crowd Favorite
- WooCommerce Scale: Mindsize
One last thing…
Of course, I should also mention that if spending a lot of time thinking about how to scale WooCommerce isn't what you want to spend your time on, I'm building a new hosting product that will help you run your WooCommerce site at scale. Automatically. Some of those tough things above are going to come included in my new product at Liquid Web.
So stay tuned…