If your product or concept suddenly gets a lot of attention, for example through a TV appearance on "Die Höhle der Löwen", a recommendation from an influencer or a large-scale marketing campaign, that means one thing: a lot of traffic on the server! Unfortunately, a little too much for some websites and servers. I'm going to introduce you to this topic in more detail today.
What happens if one member of a rowing team is weak? The entire team loses power and has to compensate for the lack of strength. If this happens during a championship, it is fatal and will almost certainly lead to defeat. The same applies to your WordPress website during high loads. If your server, your theme, your plugins, your database etc. are not a well-coordinated team, your website will collapse under peak loads - which of course wastes potential.
If your WordPress website can't cope with a sudden onslaught, the result is always the same: your website is unavailable and you indirectly lose money. So what do you need to do to prevent this from happening?
We have thought about what measures you should take, for example before a broadcast of "Die Höhle der Löwen", to prepare your WordPress website for a high load. The following steps form the basis for the best practice optimization process:
- Planning
- Optimize infrastructure
- Backend
- Front end
- Offsite
- Tests & Reporting
- Live broadcast
Based on this process and our years of experience, we have created a concrete 13-point plan to help you make your WordPress website fit for high loads.
Note
#1 Planning
1.1 Time
Unfortunately, the time you have available for implementation is often an underestimated factor in planning, but it is sometimes the most important.
You need time so that you and your team can optimize and test your WordPress website and store. You (or your web host) may also need time to move your website or domain or to scale the server.
You also need time to rethink concepts and possibly change third-party providers or plugins.
"*" indicates required fields
1.2 Rethinking concepts
Plugins, widget and resources
You should remove all resource-consuming plugins, widgets and functions that you don't absolutely need in your dashboard or on your website. Do you really need your monitoring tools such as Matomo or Google Analytics in your WordPress dashboard?
Try to limit yourself to the absolute minimum if you want your website to stay online even under the highest load. Even the smallest things like a social media button can easily double the loading time. In the following example even 12 scripts with a total of 462.7 kB - just to display a social media button.
Advertisements
Too many ads on your website not only slow down your server, but also ensure that your website is abandoned more quickly. As a result, you will lose advertising revenue. Limit yourself to a small number of high-quality ads to increase your return on investment (ROI) as quickly and efficiently as possible.
Emails
Your website is your online presence - your emails do not belong on it. The server takes up a lot of load and this is very expensive, especially at peak times.
We distinguish here between two types of e-mails:
- Marketing (Newsletter)
- Administration
Marketing emails, such as your newsletter, should always be outsourced. GDPR-compliant German providers are Cleverreach or Newsletter2Go, for example. Of course, there are also international providers such as Mailchimp or ActiveCampaign, which also do a great job.
Note: You should never send marketing emails via your website.
You can also outsource administrative emails, such as invoices, password resets, emails for account creation or similar. You should consider this, especially if there are a lot of orders with high visitor numbers.
There are also a number of providers that you can simply use as a third-party SMTP server: Mailgun is my favorite here. There is also an easy to set up WordPress plugin for this.
#2 Hosting
The most important point that you should focus your attention on is hosting. First and foremost, it is important to choose a host that has no traffic limits. Because: If your traffic exceeds this limit, your host can block your website and all your efforts will be wasted.
Hosting tariffs based on shared hosting are also completely unsuitable for a high increase in load, as you share the CPU time with other users (websites). In most cases, they are also not powerful enough to cope with traffic surges such as those seen on "Die Höhle der Löwen".
A host specializing in WordPress and WooCommerce is usually the best choice if you don't want to take meticulous care of the setup, maintenance, performance optimization and security of your website yourself. You can find out which four factors you need to pay particular attention to with WooCommerce web hosting in our article.
It may also make sense to scale up your server temporarily. This means that you scale up your server for a period of time (more CPU/RAM etc.) and then return to the regular tariff after the traffic peak to save costs.
Ideally, you should talk to your web host right at the start of the planning process. They can give you the best advice and recommendations.
#3 Backups
Backups are an absolute must, not just for peak loads, but as a general rule. Your website should be backed up automatically every night and you should also have the option of creating manual backups. This gives you an additional safety net, especially during phases such as restructuring your website.
You can also secure large milestones as versions in this way.
For example:
- Backup 1: Initial state
- Backup 2: Caching plugin installed and configured
- Backup 3: Database cleaned up
- ...
This way, you can always jump back to certain points of your customizations if something goes wrong.
I recommend that you actually use this as you work your way through this document.
3.1 Backup systems
Backup with managed WordPress web hosts (recommended):
With most specialized hosts, you can rely on a nightly automatic backup of your website. In addition, there is usually the option of creating and restoring manual backups with a single click. Since these backups do not mean any inconvenience for you and do not take up any storage space, the recommendation clearly goes in this direction.
Backup via WordPress plugin:
plugins such as BackWPup, Updraft, BackUpWordPress and similar can back up your entire WordPress website, including media and database, to your server.
Depending on the plugin and version (free or paid version), you can also save your backup in the cloud* or download it.
BackWPup is written by Inpsyde and is well supported. Therefore, this is our recommendation for you if you do not have a backup solution in your hosting package. BackWPup offers scheduled backups, storage on cloud services* such as Dropbox or Microsoft Azure or another FTP server.
In the purchase version, you can specify additional cloud services as storage space and encrypt your backups.
*Whenstoring backups in the cloud, you should think carefully about which provider you use in times of GDPR, as your backups also contain customer data such as names, addresses and emails.
#4 Caching & Minifying
The number one factor when it comes to delivering websites quickly and with as little server load as possible is clearly caching.
With caching, you minimize the requests to your server, which then delivers static files instead of dynamic content, such as your images or the HTML of your websites. In addition to an enormous improvement in speed, this also results in a significantly lower load, as the server does not have to load the same content over and over again. Think of it like your mother sending you to get milk over and over again. Instead of running out again and again, you simply fill the fridge with several bottles. This reduces the weight on your legs and the stress with your mother because you weren't fast enough.
Here we differentiate between the server-side cache and caching through plugins. We have compiled a detailed overview of the cache and the differences between these caching options for you in our caching basics article.
Minifying CSS and JS can also give you a performance advantage. This involves removing comments and spaces from the contents of the respective stylesheets and JavaScript files and merging them into one long string. We recommend the "Merge + Minify + Refresh" plugin, for example.
#5 Media optimization (scaling images, outsourcing videos)
5.1 Pictures
Large media are of course the killer in terms of load and performance. If your store subpage contains 25 product images in full resolution, even though they are only displayed in 200px x 250px, the website will quickly come to its knees.
You should be particularly careful with images in the shopping cart or checkout area, as these areas are not cached. If you load 300dpi images there at 2000px, even though only a pictogram is needed, you can be sure that nobody will be able to buy anything at full load.
We explain which WordPress plugins you can use to automatically prepare your images in our image optimization plugin comparison.
5.2 Videos
Videos belong on video portals and are then embedded on your website! At least if you're purely concerned with performance. There is hardly any reason to host videos yourself (in some cases perhaps the GDPR, but let's leave that aside here).
If you absolutely want to host videos yourself, do it on a dedicated server and then embed them on your site. Otherwise, upload them to YouTube, Vimeo, 3q or Brightcove.
#6 Clean up database
Now let's go into the depths of WordPress IT: the database.
Very important: Make a backup first!
WordPress stores posts, comments, pages and other types of textual data in a single database (excluding images and videos, as these are located in the "wp-content/**" folder). After a while, this database naturally becomes a little fuller and "cluttered".
Garbage here means, among other things:
- Comments in the spam section
- Revisions of posts and pages
- Things in the trash
- Post and comment metadata such as validations that have long expired
This is all old load that you generally no longer need and which pulls your server down.
How do you get rid of this stuff?
TL;DR & for all those who want to have it a little easier: Install WP-Optimize and let it run!
6.1 Revisions
Revisions are interim statuses of your posts, pages and drafts.
In most cases, these can be reduced enormously, for example to a maximum of 8 to 10 revisions. In some cases, it even makes sense to switch them off completely.
Write this in your wp-config.php:
Switch off completely:
define( 'WP_POST_REVISIONS', false );
Limit revisions:
define( 'WP_POST_REVISIONS', 10 ); // Max 10 revisions
6.2 Optimizing the wp_options
The wp_options table is one of the most important and often overlooked tables in WordPress when it comes to load optimization. In addition to things like the site URL, home URL, time formats and admin data, the wp_options also contains settings for plugins, themes, WP cronjobs and cache data.
To optimize this, we first need to understand what the individual table columns mean. The wp_options has the following columns:
- option_id
- option_name
- option_value
- autoload
Let's take a look at the autoload column. This controls which options and settings are loaded via the wp_load_alloptions() function. This means: If the entry in a row is set to 'yes', this function is loaded on every page of your website.
With many plugins, the setting behind this is that it is so damn important that it has to load on every page - even though the plugin is actually only used on one page (e.g. a calculator or contact form).
This of course clutters up your website and causes enormous extra load. How do you fix this?
Ultimately, this is a question of planning. As already mentioned in point 1.2 "Rethinking concepts", you should ask yourself the question: "Do I need this plugin?". If you can replace it with another option, do it.
For example, you can load Google Analytics externally rather than in the WordPress dashboard. Or instead of using a redirect plugin, you could check with your web host to see if they have already integrated such things.
To find out which plugins cause long loading times, I have written an SQL query for you here:
SELECT option_name, length(option_value) AS option_value_length FROM wp_options WHERE autoload = 'yes' ORDER BY option_value_length DESC
After you have executed this query, you will get back a list that shows you which functions cause the most load.
In this case it comes from the plugin "Rewrite Rules". If you host with Raidboxes, you can use the rewrite rules in the Raidboxes dashboard, simply apply the rewrite rules for this box and delete the plugin.
Remove old "plugin garbage" from the wp_options
Deleted plugins like to leave remnants in the wp_options and also on autoload = yes. This is of course very bad, as the functions behind it no longer even exist and the server's computing time is therefore completely wasted.
What I always like to do is to look up the names of deleted plugins in wp_options and remove them.
Let's assume that we no longer need the "Rewrite Rules" plugin from above, so I run this SQL query:
SELECT * FROM `wp_options` WHERE `autoload` = 'yes'AND `option_name` LIKE %rewrite_rules%'
Important
It is possible that your database prefix is different, so you may have to adjust this query at the "wp_options" position to "deinprefix_options".
I then get back a whole series of functions that are no longer required, all of which are still set to autoload = yes, but are completely useless. I simply delete them. I already mentioned backups, didn't I? 😉
I go through this procedure for all plugins. The wp_options is now a whole lot easier.
6.3 Deleting old transients
Update
Since WordPress Ver. 4.9.9 this is no longer necessary, as WordPress takes over this task itself.
For WordPress versions prior to 4.9.9:
Transients are nothing more than temporary options that are stored in the database for a short time. As soon as they have expired and are no longer needed, they are deleted. For example: "site_transient_update_plugins" simply contains the information about which plugins have an update and which do not. As soon as these plugins are updated or a new update check is started, this transient is deleted.
Unfortunately, this is not always the case, because some transients get stuck in the database forever and make queries difficult. These should of course be removed.
It is best to use the Transient Cleaner for this, as doing this manually is a huge effort. Once you have successfully used this plugin, you can safely remove it again. The Transient Cleaner only removes the expired transients and nothing else - a great tool!
6.4 WordPress sessions
Sessions are used to control, log, check and run user login sessions. After a while, a WP cronjob deletes these sessions from the database. At least that's how it should be.
Unfortunately, cronjobs hang up or are deactivated by plugins - then you have a lot of sessions in the database in no time.
To see if you are affected by this, I have another SQL query for you:
SELECT * FROM `wp_options` WHERE `option_name` LIKE '_wp_session_%'
Important
It is possible that your database prefix is different, so you may have to adjust this query at the "wp_options" position to "deinprefix_options".
If you find that there are thousands and thousands of entries, use the following SQL query to delete them:
DELETE FROM `wp_options` WHERE `option_name` LIKE '_wp_session_%'
At Raidboxes, we have our own server-side cron job for this, which you can control according to intervals. You can find this in your Box settings under WP Session Eraser.
6.5 Adding an index to the autoload
Ok, now it's getting tricky! But if you manage to use this trick from 10up for your WordPress website, you've gained a lot.
What he does in principle:
An index is added to the autoload field in the wp_options. This significantly reduces the query time and even brings it to a constant, very low "maximum".
The result is obvious:
The nice thing is: Our Add Index To Autoload plugin works wonderfully for most websites. As always, remember to back up beforehand!
It would work manually with this SQL query here:
ALTER TABLE `wp_options` ADD INDEX (`autoload`);
Important
It is possible that your database prefix is different, so you may have to adjust this query at the "wp_options" position to "deinprefix_options".
#7 Keep everything up to date!
A very effective way to withstand high traffic is to keep your software up to date. Not only your WordPress itself, but also your active theme, your plugins and right up front: your PHP version.
7.1 PHP
PHP is the "software engine" of WordPress. This also means that the better the performance of the engine, the faster your website will be. PHP 7.0 can already execute more than twice as many requests per second as PHP 5.6 - and with half the latency. With PHP 7.1 and 7.2, things got even faster.
Note
Official support for PHP versions prior to PHP 8.0 has already expired. You should therefore at least update to PHP 8 now so as not to jeopardize the security of your WordPress website.
Overall, it makes more than sense to use the PHP version that gives you the best performance. But beware: not all plugins and themes are compatible with the latest versions! Here, either the documentation of the plugins and themes or simple trial and error will help.
7.2 WordPress version
To get the maximum performance, your WordPress version should also be up to date. If you haven't updated your WordPress in a while, you shouldn't jump directly from one major version to the next (e.g. 4.3 to 4.4), but rather feel your way forward in minor versions (e.g. from version 4.3.3 to 4.3.4).
Always check the overall functionality of your website between updates. In principle, it is recommended that you always create individual backups of your website. This is especially important before major version changes!
A managed WordPress web host that takes care of WordPress updates for you is also generally recommended here.
7.3 Plugins and themes
Just like your WordPress version, you should also update your plugins and themes. Security and performance are the main reasons. Insecure plugins and themes can ruin all your work. You can find an overview of currently known security vulnerabilities for WordPress, themes and plugins in the "WPScan Vulnerability Database" from security provider Sucuri.
Plugin and theme updates also allow you to upgrade to a higher PHP version and thus achieve a significant performance boost. In addition, bugs are eliminated and you have more features at your disposal.
The same applies to major updates: make a backup of your website beforehand or test the new version in a staging environment. Check the functionality of your website before you go live with the changes.
The consequences of lagging behind with your plugin updates have been demonstrated, for example, by the security vulnerability of a GDPR plugin.
#8 Broken Links
A very simple point that doesn't necessarily drag down your website performance, but can cost you page views, are broken links. You can easily check your website using the online Broken Link Checker.
I recommend that you use this website instead of a WordPress plugin for the check, as plugins drag down the performance of your website - even if you're not currently using them. However, there are many other tools and methods for finding broken links. You can find out what these are in this article.
#9 Lazy Loading
Update
Since WordPress version 5.5, you no longer need a lazy loading plugin, as WordPress takes care of this task itself.
With lazy load, only the content that the user has in their visible browser area is displayed. The rest is loaded dynamically when the user scrolls down further.
To reduce the load on your website, only those requests are fulfilled that actually need to be fulfilled immediately. This includes, for example, images, videos and texts as well as scripts and other things. A real power tool - like Thor's hammer to save resources.
It works like this:
The browser already loads the entire textual content (the DOM), but uses Javascript to load only the images/video/script resources that the user actually needs. If the user scrolls down, the things that come into their field of vision are reloaded.
Many modern themes, especially for stores, have already implemented lazy loading. Unfortunately, it is not always easy to add lazy loading at a later date.
But, there is a plugin for that! There are many lazy loading plugins on the market. However, there is one that I particularly like: a3 Lazy Load. A3 Lazy Load works in many cases and can lazy load videos and iFrames in addition to images. It also supports WordPress AMP, WooCommerce and Advanced Custom Fields.
#10 Optimize the payment process
Especially if you want to sell one or more products, it is essential to optimize the payment process precisely. As mentioned above, things like the shopping cart or the checkout cannot be cached. You should therefore reduce the server load enormously here, as each request means a completely new and resource-intensive request to the server.
Use your browser tools (in Chrome, for example, via the "Network" tab) to see how many requests are generated during a checkout and which ones. If you see that you generate 400 requests just by calling up the shopping cart, something is wrong.
Investigate which plugin or resource generates many of these requests and try to reduce them. This means that you may have to get rid of plugins that you do not absolutely need.
What we often see here are fonts that are loaded and rendered from external sources, but are not even used on the shopping cart or checkout page.
Also ask yourself whether you really need to list all products with full-resolution images in the checkout display or whether a text display is sufficient.
Payment options via gateways
It may also be necessary to change your payment gateway. If, for example, your PayPal plugin takes a very long time to process requests, you may lose transactions here.
If you want to offer as many payment options as possible and secure processing, take a look at Stripe. Stripe offers simple WordPress integration and fast payment processes with a large number of payment options.
#11 CDN
On page is everything optimized now? Server fast? Great! Then comes the next step to keep the load as low as possible: A Content Delivery Network (CDN).
A CDN is essentially a copy of your cached website that is distributed on different servers in different locations around the world. This means that the end devices in one of these locations can access the data more quickly. To use the milk example from above, it's like having a fridge full of milk in every room. In addition, the CDN will also relieve your server of load, as it delivers parts of your website cached from its server.
We recommend Cloudflare as a CDN partner. Some CDN plans even include a firewall and an image optimizer. We explain how to connect Cloudflare to your Raidboxes box here:
In Cloudflare:
- Enter your domain under "Add Website" and click on "Scan DNS Records".
- CF will now automatically scan for your records - just wait until it has finished.
- CF will then make suggestions (usually two for A Records). And that's ok. Click on "Continue".
- In the next step, select your plan and click on "Continue" again.
- Here you now have nameservers that you need to customize.
- Cloudflare shows you ours and which ones you can change them to. (Of course, this only applies to domains that you have with us. If you have the domains elsewhere, you'll have to check there).
- You must then enter these nameservers (5) as nameservers in the domain administration. If you manage your domains with us, you can customize them here. There you click on "DNS" for the respective domain and change the name servers to those of Cloudflare. If you have your domains with another provider, you need to check there.
Done!
Also important: If you receive the error message: "Too many redirects", you must activate "Full Strict" in the SSL settings in Cloudflare.
#12 Reporting
You can't always keep an eye on your website everywhere, so a monitoring and uptime reporting tool is very important. These mostly free tools monitor the status of your website. They check at short intervals whether your website is accessible. We recommend the free plans from Pingdom or UptimeRobot.
Attention with the check intervals
Do not set this check too short, as this also means a load on your web server. Therefore, the check intervals should not be shorter than 5 minutes.
#13 Final backup
Everything going well? Satisfied? Great! Now you should just make a final backup. Your website shouldn't come to its knees during the next load spike from the Lion's Den and co.
Conclusion
I hope that my step-by-step guide will help you to make your WordPress website fit for high loads. If you're still struggling with the more technical aspects, we recommend that you consult a WordPress professional. Do you have any other questions or comments about preparing for high loads? Then feel free to leave me a comment!