A sluggish website or timed-out server is not ideal for business any business and brand reputation. Such downtime can have detrimental effects to profitability or trust. Websites must be able to anticipate and prepare for new traffic coming its way, so that they are proactive rather than reactive. This is simply because you never know what might trigger a temporary spike in traffic. For example, if you run a blog, it could be a post gone viral. Just a few seconds of downtime can lead to loss of thousands of dollars as most internet users are impatient. That said, WordPress is well capable of managing high volumes of traffic, though a lot of contingencies, configurations and set-ups must be intentional. Let’s take a look, shall we?
- WordPress doesn’t handle traffic. Hosts (Hosting companies) do!
As a website engine, WordPress itself isn’t mainly responsible for handling your potential high traffic. The traffic-handling capability majorly depends on your hosting platform. Unluckily, a virtual machine hosting your WordPress website can be a single point of failure as an issue with a single instance can cause a loss of service for your website. As a matter of fact, some hosting servers limit your traffic threshold while others require you to upgrade your account if your traffic increases beyond a certain threshold. So, what basics should be on our hosting provider checklist:
- Firstly, ensure your provider accommodates the latest WordPress versions effortlessly.
- Secondly, check to see if they will allow you to exceed your cap (your site’s transfer speed limit and bandwidth, when you start getting a lot more traffic)
- While shared web hosting can be great when starting out on a low traffic project, once you pick up, you’ll need to shift to a virtual private server (VPS). Your provider should have provisions for a VPS.
- Vertical scaling should be allowed with tiered plans so customers can easily upgrade to as needs change. Scaling resources to improve performance can mainly be achieved by vertical scaling. In essence, by increasing the size of the virtual machine running your WordPress website.
- Check to see if horizontal scaling is available too as it separates your website into various layers. For instance, separating front-end server, database server, proxy layer, and image layer, making it easier to scale resources.
Quick Tip: If you can, avoid deploying a cPanel/WHM (WebHost Manager) on your high-performance WordPress server as it can slow down your high traffic website.
- Utilizing Elasticsearch on your website
Particularly MySQL and MariaDB are not famous for their search capabilities. Neither were they built with that strength in mind, and it’s one of the reasons why WordPress team is not able to improve the search logic. Written in Java, ElasticSearch is distributed, fast, RESTful Search engine software meant for search and analytics. Notwithstanding, Elasticsearch can be leveraged to speed up querying of the WordPress database. Specifically by building an index of the content of your site’s database, ElasticSearch can be used to search this index much faster than a MySQL query can whilst performing the same search. Elasticsearch can also be integrated by installing ElasticPress plugin to generate query results with Elasticsearch rather than MySQL. This can improve performance and set you up better to handle high traffic.
- Less Graphics and more optimized media
To prevent website failure during spikes in traffic, you can reduce the number of graphics you have in the design of your website. The contingency of optimizing your media is ideally supposed to help make your site lighter and load faster. Getting the best page speed performance can be a good safety net during high traffic episodes. Three basic practices come to mind.
- You can use compression plugins for images and lazy loading as it will only serve images to visitors once they reach those parts of your web pages, and not sooner.
- Always ensure you limit the media on your site to only essential images, if you can.
- Furthermore, embed videos from services like YouTube and Vimeo onto your site! Then uploading full videos on your site.
- Less Plugins
Seems our theme thus far is ‘less is more’. But fret not, we still have some great tips! Ideally, WordPress Plugins are files that are “called” by your installed WordPress Theme. Plugins can easily extend functionality or add a new feature to the web system. But a poorly coded plugin often loads too much bloat even when it is not needed.
Technically a naked instance with no themes or plugins might perform pretty well under load. But who wants a naked theme? Additionally, most plugins can be unnecessarily complex and bloated. This increases page loading speed which slows down your site. So, make it a point to avoid overloading your site with plugins to avoid your theme from making too many queries to the database which can lead to increased activity on your server, which can result in potential server failure. Key points:
- Delete Unused plugins
- Turn off plugins you don’t need.
- Use essential plugins. Avoid unnecessary or experimental ones.
- Periodically audit your plugins often to assess their size and quality etc.
- Leveraging a Content Delivery Network
Hosting a web system in different geographical locations is not as simple as it sounds. The websystem may experience different loading speed depending on how far your visitor is geographically located. At such times, CDN turns out to be very helpful. CDN stores a cached version of your website resources on various servers in different parts of the world. This helps in maximizing your server’s performance ensuring traffic overages don’t occur. Using a CDN can reduce the loading speed of your website for your visitors around the world.
- Site speed increases— it loads faster.
- Allows you to handle more traffic as the load is shared between your hosting provider and the CDN platform.
- CDN helps save bandwidth on your website.
- CDN helps protect your website from denial of service (DDOS) attacks as multiple requests will be shared across multiple servers.
The most popular ‘free’ CDN alternative is Cloudfare which you can utilize on your WP site. Cloudflare Free CDN is great because of the following:
- No Bandwidth Charge: Unlike most CDN services, Cloudflare doesn’t charge you for the traffic. Most CDNs can charge you to purge your cached content from their CDN.
- Global Coverage: With over 100+ data centers across the globe, Cloudfare operates at several exchange points, and thus it is always near to your customers.
- Security: They are considered a security organization, and their “CDN” is essentially a distributed reverse proxy. Thus, add security pros to their menu.
- Consider using a Stateless Web Tier
Essentially, a stateless application requires no knowledge of previous interactions and basically stores no session information. In retrospect, a stateless application can be scaled horizontally since any request can be serviced by any of the available compute resources, basically web server instances. Consequently, when that capacity is no longer required, any individual resource can be safely terminated. For example, after running tasks have been drained or served their purpose. In a stateless web tier, resources do not need to be aware of the presence of their peers, all required is a way to distribute the workload to them. You can apply a stateless architecture to handle potential anticipated high traffic.
- Database Caching & Optimization
Database Caching is important as it will reduce the database calls and speeds up loading time of the web system. When most queries are served from the cache, the number of queries that need to hit the database is reduced. This results in improved database performance. The other way to improve efficiency of the database is by putting a cap on auto-loading queries and storing frequently accessed pieces of data in memory for low-latency access. Though it’s important to use query caching and proper indexing to improve database performance, it can reduce latency and increase throughput for read-heavy application workloads.
The database will have much more information after using it for a while which you don’t need anymore. This will reduce the performance and efficiency of the system. Revisions are one of the reasons which results in creating unnecessary information in the database. Revisions is a WordPress feature which enables you to save revisions of your pages, posts or custom post types automatically. By default, it autosaves your work after every 60 second. One can manage these autosave intervals by defining ‘WP_POST_REVISIONS’ in the ‘wp-config.php’ file. You can save revisions every 30 seconds, 2 minutes or as per your requirement. Revisions can also be completely turned off. Also you should know that turning off revisions does not improve site’s performance.
To get rid of all such unnecessary data, you need to optimize the database. WordPress primarily employs MariaDB or MySQL databases. Thus, either by optimizing MySQL/MariaDB settings or by providing more memory and processing power an overworked server can help. Also, there are various plugins available in WordPress which allows you to clean the database. The plugins help you delete the unused tags, revisions, trashed posts, etc. and will optimize your database.
- Using the right caching Plugins
When experiencing downtime, caching plugins can generate HTML files of your website, which is beneficial when traffic goes up. When choosing a caching plugin do pay attention to some aspects such as:
- Update availability
- Content delivery network and SSL Integration
- Page caching abilities
- Database caching strengths
Your caching plugin should offer CDN integration though my personal recommendation is the W3TC caching plugin.
- Ensuring Site Security
Security affects the scaling of a WordPress site as high traffic implies more potential threats to watch out for. And thus, professional security plugins can protect your website from malware, SQL injections, spam, DDoS attacks, etc. simply by offering the following:
- Active security monitoring
- Brute force attack protection
- Malware scanning
- Security monitoring and management (especially for DDoS),
- Blacklist monitoring
- Security hardening and Post-hack actions
In addition, you can take personal contingencies such as:
- Strengthening your wp-admin passwords with 2-factor authentication
- Limit login attempts on your site
- applying an antivirus to your network Use SFTP instead of FTP
- Hide wp-config.php and .htaccess files
- Use a VPN Virtual Private Network when not using a network you control.
- Use a VPS Virtual Private Server to have greater control over your server environment.
- Leverage Bytecode Caching
PHP script is parsed and compiled each time when it is executed. So ideally, by using a PHP bytecode cache, the output of the PHP compilation is stored in RAM, avoiding the same script from having to be compiled again and again. Consequently, this reduces the overheads related to executing PHP scripts, resulting in better performance and lower CPU requirements. OPcache can help with bytecode caching.
- Apply Load Balancing techniques
Load balancing effectively distributes the incoming network traffic across a group of back-end servers, a server pool or a server farm. As high-traffic websites serve thousands of users, concurrent requests are inevitable, so to cost-effectively scale, load balancing is advisable. Ideally, with a load balancer, if a single server goes down, it redirects traffic to the remaining online servers. A load balancer performs the following duties:
- It distributes network load or client requests efficiently across multiple servers.
- It ensures high reliability and availability by sending requests to online servers only.
- It provides the flexibility of adding or subtracting the servers as per the demand.
To demonstrate load balancing, we can use the example of wordpress.com (not wordpress.org) which is effectively one WordPress multisite install running across thousands of servers in multiple data centers. Particularly, WordPress.com as a site builder hosts multiple sites through its HyperDB to load balance and distribute its millions of tables throughout separated database instances, all linked to a central database. Which is why wordpress.com sites can handle high traffic seamlessly as they distribute end-user requests to multiple web server nodes, essentially load balancing.
Can a self-hosted WordPress site handle 100k simultaneous visitors?
The question of the day, right? In theory, yes, though a lot of effort will have to go into achieving this outcome. You’ll need to perform a site audit and most certainly involve:
- MySQL replication
- Static Content Offloading
- Elasticity of your server architecture.
- Reputable CDN provider
- An efficient comment management system such as Disqus
- Maximize caching efficiency
- Leverage elastic cloud deployment
- Frequently leverage Analytics & tracking tools such as WordPress Stats, and Google Analytics
- Utilize a high-performance HTTP server such as NGINX.
To say the least, a lot depends on hardware and what types of plugins you are using. You can consider using a separate cloud storage for media and uploads and then have a plugin that directs user’s uploads to the storage rather than the local file system. Alternatively, if you’re using AWS instances, consider architecting your site across multiple availability zones within a Region to increase the reliability of the overall architecture. Additionally, use SSD Drives and avoid HDD, as solid-state drives are more reliable, secure, and fast than their HDD counterparts.
In conclusion, optimized media, scripts and caching won’t really help if your server is slow, crowded, shared or improperly set up. So, I’d recommend you use a NGINX server as it’s more performance oriented. Additionally, ensure to use CDN caches and if you can, then you should go with Cloudflare for added performance boosts as it will decrease resource usage on your server, like bandwidth. Notable mentions involve keeping Your WP version and theme updated regularly. For any additional information and queries, feel free to reach out to us.