Scale a WooCommerce with many products

How many products are many products for a WooCommerce? The question itself is not so much for a WooCommerce as for any system that stores information in a database.

https://wordpress.org/plugins/woocommerce/

But to put figures, let’s say that many products are more than 3,000 products. And that, for everything I will explain below, my product test figure is 25,000, but that, in this sense, we could be talking about up to 250,000 products without problem.

By the way, if you want to test and add thousands of random products to test, you can use the WooCommerce Product Generator plugin that will generate all the products you want.

There are many factors when it comes to considering the optimization of a WooCommerce, since it is not only the number of products but the number of visits that the site has, and the number of times a shopping cart is created. The objective of this text is to explain a casuistry in which there is “a lot of everything”.

WooCommerce is a WordPress plugin, and WordPress works on different services, so let’s go in parts, from the lowest part, until we reach what is the WooCommerce optimization itself.

Hosting

To begin with, let’s talk about hosting in general. If you want an optimal WooCommerce, forget about a shared hosting, you need a VPS (which would be a hosting just for you, dedicated type). And here comes the first stumbling block, and that is that not everyone has the technical knowledge to manage it, and no matter how much they tell you, no hosting manages this, no matter how managed it is. You need a technician on your team or someone who knows Systems Administration and WordPress.

This tutorial has been created on a Clouding.io VPS. You can create your own VPS from 3€/month.

In addition, you have the possibility to create your VPS with the WordPress image in one click.

PARTNERSHIP

The second thing is what kind of infrastructure we want. When talking about VPS what we are talking about are machines that have their resources: CPU, RAM and disk. Although we can separate all the services into many, if we want to start off on the right foot, we need at least 2 VPS servers. In one, we will have the database (the MySQL) and in the other we will have the rest (the WordPress with its WooCommerce, the PHP, web server and cache).

If we do everything very well, with 2 machines of 2 CPU and 4 GB of RAM, with the sizes of SSD disk that are necessary, we should have more than enough for a WooCommerce that manages 25,000 products and has 2,500 carts a day and that could be about 25,000 visits a day. This would be a base, a minimum that would go well. And put to choose an operating system, Ubuntu Server is a good option since it keeps all the elements quite updated.

We are talking about machines that can cost about €15.00 per month (2 CPU, 4 GB of RAM and 50 GB SSD), so for 30 euros per month you can have a very optimal system with support for 100,000 carts per month without problems.

By the way, not all hosting companies do. For a normal installation, going to Google, Amazon or similar can be a waste of time and money. And other companies may have some limitations, so look for a VPS server company that gives full access to the server and, if it is managed, that details exactly what they are going to do when there is a peak of traffic and what their systems are to optimize and correct moments of saturation. If the company does not give you a clear answer, it is better to hire servers as open as possible and look for someone who knows about this.

Database

If we start with the database, we shouldn’t have anything special. We can install the latest version of MariaDB or MySQL that everything should work fine. The more modern the version of the database, the better, because it will give better performance. In addition, we must configure the database specifically for the amount of CPU and RAM we have. This configuration my.cnf will depend a lot on each system, so a professional should do it if you do not want to put incorrect figures there are memory failures or serious errors.

Web server

If we want a scalable system we must leave aside Apache HTTPD, which yes, works well and is easy for those who want to change the .htaccess, but has high memory consumption for high traffic. So, we will move to nginx that loads its configuration in memory so that it will have everything precalculated.

Obviously, we will have to configure nginx optimally at the server level, but we will also have to correctly configure the WordPress host for itself, optimizing the static elements so that they are cached on the user’s server and even on the web server itself.

PHP

If we want to make the most of it we must make sure to use the appropriate PHP version, and to begin with it must be PHP-FPM. Right now, although PHP 8.0 exists, the recommended version is 7.4. In any case, we must always make sure to use a version that works correctly with all our plugins.

At the PHP level we will have to configure all the recommended WordPress extensions (WooCommerce does not have any in particular) and we will also activate the OpCache. With this, we will activate the PHP cache itself that, while we do not make any update, will leave all the source code precalculated.

The main decision to use PHP-FPM is that, with nginx it works better, and on the other, that you can easily optimize how much consumption we want to have in this service in a simple way by configuring its threads, memory usage and amount of RAM that the server has.

Object Cache

And as the last major component, we will have to choose a cache of objects. WordPress natively supports Redis and memcached, each with its pros and cons. While it is true that memcached can be somewhat faster, the fact that it is in memory has certain disadvantages, so we will pick Redis as a more persistent and stable element as long as we have disks, at least, SSD or NVMe.

In the same way as in other cases, we must correctly choose the Redis configuration to be able to store without problem all the temporary information of WordPress and WooCommerce, which will make intensive use of this temporary data storage.

TLS + HTTP/2

Although nginx already supports it, we will choose as the optimal nginx system with HTTP/2 support, and if you put it, mount the system to support HTTP/3, and therefore, have in parallel a TLS 1.2 and 1.3 certificates, which can give you Let’s Encrypt itself for free.

Set up WordPress for hosting

Undoubtedly, the weight of hosting and all its elements is critical, but it is of very little use if we do not synchronize it with WordPress itself to activate its functionalities and take advantage of it.

In any case, we will use some plugins (the ones I will comment on, or others similar, which in part will suit you) for each of the elements.

Following the previous order of hosting elements, I will comment on a plugin for each service.

If we start with the database, in particular there is no plugin, although then we will make some changes in the configuration to make certain optimizations.

In the part of the web server we have commented several things. The first of these has been the possibility of caching and optimizing static elements, so we will use a plugin like Autoptimize that allows us to minimize and merge CSS and JavaScript. With this, we will be able to cache and optimize this part of static.

And in this part we will also do the synchronization of the page cache that will be served and optimized by the web server. In this case, a good integration with WP Super Cache should be enough.

In the PHP part we have talked about the OpCaché, so we are going to use the WP OPcache plugin that will manage the updates of plugins, themes, and the WordPress core itself.

For the cache of objects, we have decided to use Redis, so we will use a plugin like Redis Object Cache that will make us activate this service.

And to finish we have talked about HTTP / 2, and although WordPress manages this part quite well, we can always optimize a little more with HTTP2 push content.

Optimizing WordPress

Now that we have WordPress optimized for hosting, we can make certain improvements in what We have to WordPress itself. One of the simplest ways to find a problem is through Site Health, which we can improve and expand with the Health Check & Troubleshooting plugin and which will be very useful in case of problems.

The next thing will be to optimize the WP-Config.php. Some of the elements that we will have to review are that of WP_POST_REVISIONS, which we will leave in false. This is important because otherwise, every time we update a product or content it will generate a copy of it and multiply the database, which is one of the things we do not want.

Another element that we can review is the MEDIA_TRASH, that we can leave in true, or the EMPTY_TRASH_DAYS one that we can leave in 7 (days) or the WP_MAIL_INTERVAL a 86400 (one day) so that the system is not trying to find mail that nobody uses.

Two important elements are the one of WP_MEMORY_LIMIT, which we will leave in 128M and the WP_MAX_MEMORY_LIMIT one we will leave in 256M. For this to be of any use you have to review and reconfigure the PHP itself, that many people change this data and, if you do not optimize the PHP it is useless.

We will enable cache usage using WP_CACHE truea, configure a unique identifier in WP_CACHE_KEY_SALT , and enable CSS and JavaScript compression with COMPRESS_CSS and COMPRESS_SCRIPTS to true. We will also validate that Gzip is activated, either at the WordPress level with ENFORCE_GZIP truea , and on the web server.

Crons

A crucial element of optimization is that of the crons, which are the scheduled tasks. By default, WordPress uses a pseudo-crones system that runs when a user visits the web, and if we have a lot of traffic it is not a good idea, so in the WP-Config we will configure the DISABLE_WP_CRON a false, and we will launch the cron from the server.

Picking up the garbage

WordPress by default does a couple of things that are not very optimal, that we say. The first of these is to store a history of almost everything, in addition to storing the items that we leave in the trash for up to a month. This causes the database to fill with garbage. And to clean the database and throw away the garbage we will use a plugin of the style to WP-Optimize that will allow us to eliminate at a stroke the revisions of entries, automatic drafts, the trash, or the comments in Spam.

WooCommerce

Considering that WooCommerce is a product of Automattic, and that this company has many employees collaborating on WordPress itself, there is little to optimize because in general WooCommerce and WordPress get along very well…

WooCommerce works very well, with 100 or 100,000 products, so if you had a problem, it wasn’t from WooCommerce and it’s probably already been fixed with everything that’s been explained previously.

WooCommerce and more

If we want WooCommerce to work well, we have to avoid filling it with added plugins. We have the bad habit of wanting to look for a thousand functionalities in plugins that can probably be done in a much simpler way with some small custom plugins. As much as possible, avoid using plugins added to WooCommerce.

On the other hand, avoid using visual editors such as Elementor, Divi or similar because they contribute absolutely nothing. WooCommerce has done a fantastic job adding all the possible blocks to the WordPress block editor being able to include almost anything almost anywhere, so any visual editor besides the native one will simply generate noise and slowness.

And most of all, never use WPML because anything you want to do multi-language, multi-currency or multi-country will be thrown away completely. If you want to scale a WooCommerce internationally, use MultilingualPress and WordPress MultiSite which has perfect optimizations for this.

Conclusion

If you use WooCommerce, set up the server very well, and you will have no problems regardless of the size of the site.


About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.