13 Necessary Measures for Your WordPress to Handle High Load

Matthias Held Updated on 07.10.2020
16 Min.
WordPress -load
Last updated on 07.10.2020

A TV appearance on "The Lion's Den", an influencer's recommendation or a large-scale marketing campaign - all of these could lead to a sudden increase in interest in your product or concept. This means one thing: a lot of traffic on your server! For some sites and servers too much. Our "Head of Development" Matthias explains how to survive heavy traffic.

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:

  1. Planning
  2. Optimize infrastructure
  3. Backend
  4. Frontend
  5. Offsite
  6. Tests & Reporting
  7. Live connection

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.

Note

The 13 measures are sorted according to planning and execution and not according to their importance. We recommend completing all the points in the order we've given.

WordPress  high load - planning

#1 Planning

1.1 Time

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.

13 Necessary Measures for Your WordPress to Handle High Load

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.

Loading scripts from Social Media Button

Advertisements

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).

Emails

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)
  • Administration

Marketing mails like your newsletter should always be outsourced. GDPR-compliant, European providers include Cleverreach , Newsletter2Go. Other international providers such as Mailchimp or ActiveCampaign also do a great job.

Note: You should never send marketing mails via your website.

Administrative emails, including invoices, password resets, emails for account creation etc. can also be outsourced. You should consider outsourcing when high visitor numbers also increase the likelihood of a lot of orders.

There are also several providers here that you can simply use as third-party SMTP servers: Mailgun is my favorite among them. The developers have also created a simple-to-use WordPress plugin.

WordPress  high load - hosting

#2 Hosting

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 host specialized in WordPress and WooCommerce is the best option in most cases if you don't want to take care of the setup, maintenance, performance optimizations, and security of your site yourself. Find out what four factors you need to pay close attention to when choosing a provider in our article .

Ebook WooCommerce

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.

WordPress  high load - backups

#3 Backups

Backups are an absolute must, not only for peak loads, but as a matter of principle. Your website should be backed up automatically at night and you should also have the option to create manual backups. This gives you another safety net, especially during phases such as restructuring your website.

This way you can secure large milestones by saving different versions along the way.

For example:

  • Backup 1: Initial site version
  • Backup 2: Caching plugin installed and configured
  • Backup 3: Database cleaned up

So you can always jump back to certain points of your adjustments if something goes wrong.

I strongly recommend you create backups as you work your way through the steps in this guide.

3.1 Backup systems

Backups with managed WordPress hosts (recommended):
With most specialized hosts, you can count on an automatic backup of your site being created every night. It's usually also possible to create and restore manual backups with one click. This is certainly the method we recommend as these backups don't inconvenience you in any way or use up any of your storage space.

Backup via a WordPress plugin:
Plugins like BackWPup, Updraft, BackUpWordPress, and many more can be used to save 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 developed by the team at Inpsyde and is well supported. We recommend using it if you don't have a backup solution in your hosting package. BackWPup offers scheduled backups and storage on cloud services* like Dropbox, Microsoft Azure, or any other FTP server.

In the paid version, you can enter additional cloud services as storage space and encrypt your backups.

*
Your backups also contain customer data such as names, addresses, and emails. In times of GDPR, you need to carefully consider which provider you're using when storing backups in the cloud.

WordPress  high load - caching

#4 Caching & Minifying

The number one factor when it comes to delivering sites fast and with as little server load as possible is, of course, 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 caching by plugins. For a detailed overview of the cache and the differences between these caching options, check out the Caching basics article we've put together for you.

The Minifying CSS and JS files you can improve performance. You remove comments and empty spaces from your respective stylesheets and JavaScript files and merge them into one long string. We recommend, for example, the plugin "Merge + Minify + Refresh”.

WordPress  high load - optimize images

#5 Media optimization (scaling images, outsourcing videos)

5.1 Images

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.

We explain which WordPress tools you can use to process your pictures automatically in our comparison of image optimization plugins.

5.2 Videos

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.

WordPress  high load - clean up database

#6 Clean up your database

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.

13 Necessary Measures for Your WordPress to Handle High Load

How do you get rid of this stuff?

TL;DR & for all those who want it a little easier: Install WP Optimization and let it run!

6.1 Revisions

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 );

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. 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:

  • option_id
  • option_name
  • option_value
  • autoload

Let's take a look at the autoload column. This controls which options and settings can be changed using the wp_load_alloptions() function. If the entry in a line is set to 'yes', this function will be loaded on every page of your website.
Many plugins and theme developers believe their plugin or theme is so incredibly important that it should be loaded on every single page. Even though the plugin is actually only used on one page, e.g. a calculator or contact form.

Of course, this clutters your site and causes enormous extra load.

How do you remedy 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
Important

(Important: Your database prefix could be different, so you may need to adjust this query at the "wp_options" location in "yourprefix_options")

After executing this query, you'll receive a list showing which functions are causing the most load.

WordPress high load: wp_options autoload query

In the example above, the plugin "Rewrite Rules" is responsible for the heavy load. If you host with RAIDBOXES, you can use the rewrite rules function for this BOX in the RAIDBOXES Dashboard and simply delete the plugin.

WordPress high load: URL Rewrites RAIDBOXES

Remove old "plugin waste" from the 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%'.
Important

(Important: Your database prefix could be different, so you may need to adjust this query at the "wp_options" location in "yourprefix_options")

I then receive a whole bunch of functions back that are still set to autoload=yes but are completely useless.
So, I just delete these. I already mentioned backups, right? 😉

I repeat this procedure for every deleted plugin. The wp_options is now a lot less cluttered than before.

6.3 Delete expired transients

Update: From version 4.9.9 WordPress takes care of this task automatically so you no longer need to complete this step by yourself.

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. They get deleted once they've expired and are no longer needed. For example, "site_transient_update_plugins" simply contains information about which plugins have an update and which do not. As soon as you update the plugins or start a new update check, this transient is 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.

It's best to use the plugin Transient Cleaner, trying to remove the transients manually requires a lot of effort. After you've finished deleting the transients you can just delete the plugin. The Transient Cleaner only removes the expired transients and nothing else - it's a great tool!

Performance Fairs E-Book

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_%'.
Important

(Important: Your database prefix could be different, so you may need to adjust this query at the "wp_options" location in "yourprefix_options")

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 cron job, which you can set to run at intervals. You can find it in your BOX settings under WP Session Eraser.

WordPress high load: WP Session Eraser

6.5 Add an index to autoload

Okay, things are about to get tricky. But if you do manage to implement this trick from the colleagues at 10up into your WordPress site, you'll benefit a lot from it.

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:

WordPress high load: wp_options Query Time Index
Source: 10up

The best part: For most sites the plugin Add Index To Autoload works perfectly. As always, don't forget to create a backup in advance!

If you'd prefer to do it manually, you can use this query:

ALTER TABLE `wp_options` ADD INDEX (`autoload`);
Important

(Important: Your database prefix could be different, so you may need to adjust this query at the "wp_options" location in "yourprefix_options")

WordPress  high load - updates

#7 Keep everything up to date!

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.

7.1 PHP

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.

Note

Official support for PHP 5.6, 7.0 and 7.1 has already ended and PHP 7.2 will only receive security updates until December 6, 2021. You should therefore update to at least PHP 7.2 to keep your WordPress site secure.

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.

PHP versions RAIDBOXES

7.2 WordPress

To get the maximum performance out of your WordPress, you should also use a current version. If you haven't updated your WordPress for a while, you shouldn't jump directly from one major version to the next (e.g. from 4.3 to 4.4). You should test the waters first by moving forward in minor versions (e.g. from 4.3.3 to 4.3.4) instead.

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.

We recommend using a managed WordPress host as these can also take care of WordPress updates for you.

7.3 Plugins and Themes

Just like your WordPress version, you should also keep your plugins and themes up to date. The main reasons behind this are security and performance. Unsafe plugins and themes can destroy all your hard work. You'll find an overview of all the current security vulnerabilities for WordPress, themes and plugins in the "WPScan Vulnerability Database" from security firm 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 same applies for larger plugin and theme updates: Make a backup of your site beforehand or test the new version in a Staging environment. Check the functionality of your site before you go live with any changes.

A lot of users felt the consequences of lagging behind with their plugin updates recently after a vulnerability in a GDPR plugin was discovered.

WordPress  high load - Broken LInks

#8 Broken Links

While broken links don't necessarily affect your site's performance, they do cost you visitors. You can use the Online Broken Link Checker to easily check for broken links on your site.

I recommend using this website to check rather than a plugin. Plugins reduce the performance of your website even when you're not actively using them. There are also plenty of other ways to find broken links. Find out more about the different tools and methods in this article.

WordPress  high load - lazy loading

#9 Lazy loading

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:

The browser already loads the entire textual content (the DOM), but uses Javascript to load only those images/video/script resources that the user needs at that moment. If the user scrolls deeper, the things that come into his field of vision are reloaded.

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 loading plugins on the market. But there's one I particularly like: a3 Lazy Load. The plugin a3 Lazy Load works well for most sites and can load videos and iFrames lazy in addition to images. It also supports WordPress AMP, WooCommerce, and Advanced Custom Fields.

Update: You don't need a lazy loading plugin from WordPress Version 5.5 as WordPress now takes care of this task for you.

WordPress  high load - payment process

#10 Optimize payment process

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.

13 Necessary Measures for Your WordPress to Handle High Load

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 secure transactions, take a look at Stripe as an option. Stripe offers easy WordPress integration and fast payment transactions with a large number of payment methods.

WordPress  high load - CDN

#11 CDN

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 a CDN partner the company Cloudflare. Some CDN plans even include a firewall and image optimizer. Let me show you how to connect Cloudflare with your BOX at RAIDBOXES:

In Cloudflare:

  1. Enter your domain under "Add Website" and click on "Scan DNS Records".
  2. Now CF automatically scans for your records - you just need to wait until it's complete.
  3. Once the scan is complete, CF will give you suggestions (usually two for A records). That's fine. Click on "Continue".
  4. Select your plan in the next step and click "Continue" again.
  5. Now you'll see the name servers you have to update.
  6. 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).
  7. You need to enter these name servers (5) as name servers in the domain administration. If you manage your domains with us, you can go here to make the changes. 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'll need to make the changes there.

Ready!

Important: If you receive the error message: "Too many redirects", you need to enable "Full Strict" in the SSL settings in Cloudflare.

WordPress  high load - reporting

#12 Reporting

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.

We recommend the free plans from Pingdom , UptimeRobot.

Caution: Don't have these checks take place too frequently as this is also a load on your web server. The intervals shouldn't be shorter than every five minutes.

#13 Final backup

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.

Final Thoughts

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!

Matthias is the Chaos Calmer at RAIDBOXES. As a plugin and theme developer, WordCamp speaker and active hosting community contributor, he can regularly be found at WordCamps and other WordPress events and is partial to a snack while snacking. If he's not there, he's somewhere with a lap full of cats.

Related articles

Comments on this article

Write a comment

Your email address will not be published. Required fields are marked with * .