If your product or concept suddenly gets a lot of attention, e.g. through a TV appearance on "Die Höhle der Löwen", the recommendation of an influencer or a large-scale marketing campaign, this means one thing: a lot of traffic on the server! For some sites and servers too much. Our 'Head of Development' Matthias explains how your WordPress can survive high loads.
What happens when one member of a rowing team weakens? The performance of the whole team drops and everyone needs to compensate for the loss of strength. If this happens during a championship, the effect is disastrous and will most certainly lead to a defeat. The same applies to your WordPress website during high load. If your server, your theme, your plugins, and your database are not a well-rehearsed team, your website will collapse during traffic peaks and you'll lose valuable visitors.
The result is always the same when your WordPress site can't withstand a sudden rush of visitors. Your website isn't accessible, the potential buyer doesn't get anywhere and you lose money. So what can you do to prevent this from happening?
We've had a think about what measures you could take to prepare your WordPress site for heavy traffic after an appearance the TV show "The Lion's Den". The basis for the best-practice optimization process is the following steps:
- Optimize infrastructure
- Tests & Reporting
- Live stream
Based on this process and our years of experience, we've created a solid 13-point plan to help you get your WordPress site ready for heavy traffic.
The time you have available for the implementation is often an underestimated planning factor but it is one of the most important.
You need time for you and your developers to optimize and test your site and your shop. You, or your host, may also need time to move your website or domain or scale the server.
You also need time to rethink concepts and possibly change third-party providers or plugins.
1.2 Rethinking concepts
Plugins, widgets and resources
You should remove all resource-hungry plugins, widgets and features that you don't need in your dashboard or on your site. Do you really need your monitoring tools like Matomo or Google Analytics in your WordPress dashboard?
Try to limit yourself to the absolute minimum when it comes to keeping your website online under heavy load. Even the smallest things like a social media button can easily double the loading time. In the following example, there are even 12 scripts with a total of 462.7 kB - just for displaying a social media button.
Too many ads on your site not only slow down your server, they also make your potential customers more likely to leave your site. As a result, you lose out on advertising revenue. Limit yourself to a few, high-quality ads to quickly and efficiently increase your return on investment (ROI).
Your website is your online presence - you shouldn't be sending your emails from here. The server takes a lot of load and this is especially at your expense during high load peaks.
We distinguish here between two types of email:
- Marketing (newsletter)
Marketing emails such as your newsletter should always be outsourced. GDPR -compliant, european providers here are for example Cleverreach or Newsletter2Go. Of course, there are also international providers such as Mailchimp or ActiveCampaign, which also do a great job.
Note: You should never send marketing mails via your website.
Administrative emailsYou can also outsource administrative emails, such as invoices, password resets, account creation emails and the like. Especially if there are a lot of orders when you have a high number of visitors, you should consider this.
The most important directly actionable point you should focus your attention on is, in fact, your hosting. First and foremost, it's important to choose a host with no traffic limitations. Otherwise, if your traffic exceeds a set limit, your host can block your site and all the effort you've put in would've been for nothing.
Hosting based on shared-hosting plans is also completely unsuitable for a growth in traffic as you share CPU time with other users (websites). In most cases, these plans aren't powerful enough to withstand the kinds of traffic surges you'd experience after appearing on "The Lion's Den".
A WordPress and WooCommerce host is in most cases the best choice, if you don't want to take care of the setup, maintenance, performance optimizations and security of your site yourself. Which four factors you have to pay special attention to when hosting WooCommerce, you can read in our article.
A short-term scaling of your server might also be a good idea. This means you scale up your server for a period of time (more CPU/RAM etc.) and then return to the regular plan after the traffic peak to save costs.
Ideally, you can talk to your host at the beginning of the planning. They can give you the best advice and recommendations.
Backups are an absolute must, not only for peak loads, but as a matter of principle. Your website should be backed up automatically every night and you should also have the option to create manual backups. This gives you an additional safety net especially in phases such as restructuring of your site .
This way you can secure large milestones by saving different versions along the way.
- Backup 1: Initial site version
- Backup 2: Caching-plugin installed and configured
- Backup 3: Database cleaned up
- … and so on
This way, you can always jump back to specific points in your adjustments 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 hosts (recommended):
With most specialized hosters you can rely on a nightly automatic backup of your site . In addition, there is usually the possibility to create and restore manual backups with one click. Since these backups don't mean any inconvenience for you and don't take any storage space away from you, the recommendation clearly goes in this direction.
Backup via WordPress -Plugin:
Plugins like BackWPup, Updraft, BackUpWordPress and many more can backup your entire WordPress site , including media and database, on your server.
Depending on the plugin and the version you're using (free or paid), you can also save or download your backup in the cloud*.
BackWPup is from the colleagues of Inpsyde and is well supported. So this is our recommendation for you if you don't have a backup solution in your hosting package. BackWPup offers scheduled backups, storage on cloud services* like Dropbox or Microsoft Azure or another FTP server.
In the purchase version, you can specify additional cloud services for storage and encrypt your backups.
*When storing backups in the cloud, you should think carefully about which provider you use in times of GDPR , since your backups also contain customer data such as names, addresses and e-mails.
The number one factor when it comes to delivering sites quickly and with as little server load as possible is clearly caching.
You minimize the requests to your server, which then delivers static files instead of dynamic ones, such as your images or the HTML of your pages. This not only improves the speed of your server but also reduces its load as it doesn't have to load the same content over and over again. Imagine for a minute your mother keeps sending you to fetch milk from the store. And, instead of going out each time, you then just fill the refrigerator with several bottles. This reduces the load on your legs and you have less stress with your mother for not being fast enough.
Here we distinguish between the server-side cache and the caching by Plugins. We have provided a detailed overview of caching and the differences between these caching methods in our Caching Basics article for you.
In terms of load and performance, large media items are obviously the biggest killer. If your shop subpage contains 25 product images in full resolution, even if they're only displayed in 200px x 250px, your site is quickly brought to its knees.
You need to be especially careful with images in the shopping cart or checkout area as these areas are uncached. If you load 300dpi images at 2000px when you only really need one pictogram, you can be sure that swathes of customers won't be able to complete their purchase during full load.
With which WordPress -Plugins you can prepare your images automatically, we explain in our image optimization-Plugin-comparison.
Videos belong on video portals and can then be integrated into your site. Especially if you're just focusing on performance. There are hardly any reasons why you'd want to host videos yourself (in some cases perhaps due to GDPR, but let's leave that aside).
If you really want to host videos yourself, do it on a dedicated server and then host them on your site. Otherwise, just upload them to YouTube, Vimeo, 3q, or Brightcove.
Now let's get deep into WordPress IT: the database.
First things first: Make a backup before you start!
WordPress stores posts, comments, sites and other types of textual data in a single database (images and videos are not included, these are located in the "wp-content/**" folder). After a while, this database tends to get a bit full and "cluttered".
When we say "clutter", we're talking about:
- Comments in the spam area
- Blog and page edits
- Items in the trash
- Post and comment meta data such as long-expired validations
These are all legacy files you're unlikely to ever need again and they're just weighing your server down unnecessarily.
How do you get rid of this stuff?
TL;DR & for those who want it a little easier: Install WP-Optimize and let it run!
Revisions are the interim stages of your posts, pages and projects.
Usually these can be reduced enormously, e.g. to a maximum of 8-10 revisions. In some cases, it even makes sense to switch them off completely.
Add the following to your wp-config.php file:
Switch off revisions entirely:
define( 'WP_POST_REVISIONS', false );
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. The wp_options table contains things like the site URL, home URL, time formats, admin data, plugin settings, themes, WP cron jobs, and cache data.
To optimize this table, we first need to understand what the individual columns mean.
The wp_options table has the following columns:
Let's take a look at the autoload column. This controls which options and settings are loaded via the function wp_load_alloptions() function. This means: If the entry in a row is set to 'yes', this function will be loaded on every site of your website.
Many Plugin and Theme developers have the attitude that their Plugin/Theme is so damn important that it has to load on every site , even though their Plugin is actually only used on one site (for example, a calculator or contact form).
Of course, this clutters your site and causes enormous extra load.
How do you fix this?
This is ultimately a question of planning. As mentioned in point 1.2 "Rethinking concepts", you should ask yourself whether you really need this plugin? If you can replace it with another option, do so.
For example, you can load Google Analytics externally and not from the WordPress dashboard. Or, instead of using a redirect plugin, you could check with your host to see if they've already integrated such functions.
I've written an SQL query for you to find out which plugins are causing long loading times:
SELECT option_name, length(option_value) AS option_value_length FROM wp_options WHERE autoload = 'yes' ORDER BY option_value_length DESC
After executing this query, you'll receive a list showing which functions are causing the most load.
In this case, it comes from the plugin"Rewrite Rules". If you host at Raidboxes , you can use the rewrite rules in Raidboxes-Dashboard , simply adopt the rewrite rules for this BOX and delete the plugin.
Remove old "Plugin-garbage" from wp_options
Deleted plugins have a nasty habit of leaving remnants in the wp_options and also on autoload = yes. This is, of course, absolutely useless. The functionality the code once enabled doesn't even exist anymore and it just means your server's computing time is being wasted for nothing.
What I like to do is always look up and remove the names of deleted plugins in the wp_options.
Let's assume we no longer need the "Rewrite Rules" plugin mentioned above. So I run the following SQL query:
SELECT * FROM `wp_options` WHERE `autoload` = 'yes'AND `option_name` LIKE %rewrite_rules%'
I then get back a whole series of functions that are no longer needed, 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'll just delete them.
I repeat this procedure for every deleted plugin. The wp_options is now a lot less cluttered than before.
6.3 Deleting old transients
Update: Since WordPress Ver. 4.9.9 this is no longer necessary, since 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 expire and are no longer needed, they are deleted. As an example: "site_transient_update_plugins" simply contains the info which Plugins have an update and which do not. As soon as you update this Plugins or start a new update check, this transient will be deleted.
Unfortunately, this doesn't always go as planned. Some transients stay in the database forever and make queries difficult so we need to remove them.
The best way to do this is to use the Transient Cleanerbecause doing this manually is a huge hassle. After you have successfully used this Plugin , you can safely remove it afterwards. The Transient Cleaner only removes the expired transients and nothing else - a great tool!
6.4 WordPress sessions
Sessions are used to control, log, review, and run user login sessions. After a while, a WP cron job deletes these sessions from the database. At least that's what's supposed to happen.
Unfortunately, cron jobs can hang or get deactivated by a user or a plugin. You quickly end up with loads and loads of sessions in your database.
I have another query for you to check whether you're affected:
SELECT * FROM `wp_options` WHERE `option_name` LIKE '_wp_session_%'
If you come across thousands of entries, use the following query to delete them:
DELETE FROM `wp_options` WHERE `option_name` LIKE '_wp_session_%'
At Raidboxes we have our own server-side CronJob for this purpose, which you can control according to intervals. You can find this under your BOX settings under WP Session Eraser.
6.5 Adding an Index to the Autoload
Okay, here's where it gets tricky! But if you can manage to use for your WordPress site this trick from the guys at 10up you have gained a great deal.
What this trick basically does:
An index is added to the autoload field in the wp_options. This reduces the query time considerably and even brings it to a constant, very low "maximum".
The result is obvious:
The nice thing is: For most sites our Plugin Add Index To Autoload works wonderfully. As always, remember to backup beforehand!
If you'd prefer to do it manually, you can use this query:
ALTER TABLE `wp_options` ADD INDEX (`autoload`);
A very effective way to withstand traffic surges is to keep your software up to date. We're not just talking about WordPress itself, but also your active theme, your plugins, and, very importantly, your PHP version.
PHP is the "software engine" of WordPress. The more powerful the engine is, the faster your site will be.
PHP 7.0 is able to execute more than twice as many requests per second as PHP 5.6 - and in half the latency time. The whole thing got even faster with PHP 7.1 and 7.2.
Using the PHP version that gives you the best performance obviously makes the most sense. But beware: Not all plugins and themes are compatible with the latest versions! You can check the plugin or theme documentation for this information or simply test a different version.
To get the maximum performance out of it, your WordPress version should also be up-to-date. If you haven't updated your WordPress for a while, you should not 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 entire functionality of your site between updates. I strongly recommend you keep making individual backups of your site, especially before major version upgrades.
In principle, it is also advisable to use a Managed WordPress web hostwhich takes over the WordPress -Updates for you.
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. An overview of currently known vulnerabilities for WordPress , Themes and Plugins can be found in the "WPScan Vulnerability Database"from the security vendor Sucuri.
Updating plugins and themes also allows you to upgrade to a higher PHP version and get a significant boost in speed. Bugs are eliminated along the way and you'll also get access to even more features.
The consequences of lagging behind with your Plugin updates have been demonstrated, for example, with the security breach of GDPR -Plugins showed.
#8 Broken links
A very simple point that does not necessarily drag down your sites performance, but can cost you visitors, are broken links. You can easily check your site with the Online Broken Link Checker to do it.
I recommend you to use this website instead of WordPress -Plugins for the check, because Plugins pulls down the performance of your site - even if you don't use it at the moment. But there are many more tools and methods to find broken links. You can find out what they are in this post.
With lazy loading, only the contents that the user has in their visible browser area are displayed. The rest is loaded dynamically as the user continues to scroll down.
To reduce the load of your site, only those requests are fulfilled that really have to be fulfilled immediately. This includes pictures, videos, texts, scripts, etc. Lazy loading is a genuine power tool, it's basically the Thor's hammer for saving resources.
Here's how it works:
A lot of modern themes, especially for shops, have lazy loading already implemented. Unfortunately, it's not always easy to add lazy loading at a later point.
But wait, there's a plugin for that!
There are many lazy loadingPlugins on the market. However, I like one in particular: a3 Lazy Load. A3 Lazy Load works in very many cases and can lazy load videos and iFrames in addition to images. It also supports WordPress AMP, WooCommerce and Advanced Custom Fields.
Update: Since WordPress version 5.5 you don't need a lazy loading-Plugin anymore, because WordPress takes care of this task itself.
If you want to sell one or more products, it's essential to optimize the payment process thoroughly.
As mentioned above, areas like the shopping cart or the checkout are not cachable. This is where you need to greatly reduce your server load because a new and performance-draining request is sent to the server each time.
Check your browser tools (in Chrome e.g. the tab "Network") to see which and how many requests are generated during checkout: If you see that you generate 400 requests just by opening the shopping cart, something's not right.
Check which plugin or resource is generating many of these requests and try to reduce them. This could mean deleting plugins that you don't really need.
What we often see here are fonts that are loaded from external sources, then rendered, but not even being used on the shopping cart or checkout page.
Ask yourself whether you really need to have all products listed with pictures in full resolution in the checkout area or whether a textual display would be enough.
Payment options via gateways
You might also need to change your payment gateway. If your PayPal plugin, for example, takes a long time to process user requests, you may end up missing out on transactions.
If you want to offer your customers as many payment options as possible and provide yourself with a secure transaction, check out Stripe check it out. Stripe offers easy WordPress integration and fast payment transactions with a high number of payment options.
Is your on-page optimization complete? Is your server fast? Great! Now comes the step to keep the load as low as possible: A Content Delivery Network (CDN).
A CDN is basically a copy of your cached site, which is distributed on different servers in different locations around the world. This way, users in different locations can access the data faster.
Using the milk example from earlier, this would be like having a refrigerator full of milk in each room.
What's more, the CDN will also reduce your server load as it caches parts of your website from its server.
We recommend as CDN partner Cloudflare. Some CDN plans even include a firewall and an image optimiser. We explain here how to connect Cloudflare at Raidboxes with your BOX :
- Enter your domain under "Add Website" and click on "Scan DNS Records".
- Now CF automatically scans for your records - you just need to wait until it's complete.
- Once the scan is complete, CF will give you suggestions (usually two for A records). That's fine. Click on "Continue".
- Select your plan in the next step and click "Continue" again.
- Now you'll see the name servers you have to update.
- Cloudflare shows you ours and which ones you can change it to. (Of course, this only applies to domains you have with us. If you have the domains somewhere else, you have to make the changes with that domain host).
- You must then enter these name servers (5) as name servers in the domain administration. If you manage your domains with us, you can enter them here adjust them. 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 have to check there.
Also important: If you receive the error message: "Too many redirects", you must activate "Full Strict" in the SSL settings in Cloudflare .
You can't keep your eyes on your site all the time so it's important to have tools for monitoring and uptime reports.
These mostly free tools monitor the status of your website. At short intervals, they check if your site is reachable.
AttentionDo not set this check too short, this also means a load on your web server. Therefore the check intervals should not be shorter than 5 minutes.
Is everything up and running now? You're happy with the results? Perfect! Now would be a great time to make one final backup! There's no reason why the next peak load from a mention on The Lion's Den should cause your site to go down.
I hope these step-by-step instructions will help get your site ready for heavy loads. If you do have any trouble with the more technically demanding parts, we recommend bringing a professional WordPress developer on board. Do you have any further questions or remarks about preparing for heavy loads? Then please leave me a comment!