WordPress is only at its best when raised in the proper conditions. Here are a few things you should try if you find that high traffic is limiting your blog’s performance.
If you are preparing for really high traffic, you should consider splitting your WordPress application into as many separate layers as possible. You should also consider serving those layers independently. Instead of a single host machine running your web server and MySQL/MariaDB, your site speed and resiliency will be running in concurrent layers.
See this example:
- Apache2 / nginx web front-end server(s) – to handle actual page rendering and site administration.
- MySQL/MariaDB database server – or master/slave, using a read-replica.
- Varnish / nginx HTTP proxy layer – to handle initial requests from users.
- CDN or image server – to serve media files that support your site.
Your site will not only be able to take more load in this architecture, but you can then identify stress-points that you should address specifically. It’s possible that your MySQL/MariaDB database is performing poorly, or Apache2 needs more CPU, and so forth. Under the right design, these layers may also scale out and in, or up and down, with your traffic.
W3 Total Cache (W3TC) is the latest generation in WordPress performance plugins. It combines the research of web development authorities to provide an optimal user experience for WordPress sites.
W3TC is unique with ability to optimize server side and client side performance, adding functionality otherwise unavailable natively:
- Page Caching: W3TC helps to decrease response time by creating static HTML versions of pages. This allows web servers to serve them without invoking PHP. It automatically updates the cache when comments are made or pages are edited.
- Database Caching: Database queries (objects) are also cached, allows many sites to reduce the time needed to generate new pages. This is especially useful for sites that receive a lot of comments.
- Headers: W3TC manages the headers (entity tag, cache-control, expires) which control the caching of files in web browsers, reducing server load and improving the user’s perceived performance.
You can use W3TC to optimize WordPress in both single- and multi-server environments through either shared or dedicated hosting.
Varnish gives excellent performance, but you should be aware that Varnish is “allergic” to cookies. If deployed with default settings, Varnish won’t recognize or honor normal WordPress cookies for logged in users. Therefore, you should write the configuration file so that the presence of WordPress cookies triggers Varnish to bypass the cache and send the request on to the web server directly. In effect this means that logged-in users will make requests directly to the web server, while public users will make their requests from the Varnish cache. A quick search of GitHub will provide a variety of VCL configuration files specifically written to work with WordPress, such as DreamHost’s WordPress VCL example.
You should also know that Varnish, like most other caching mechanisms, will serve up the same content from the cache until it expires. This means that administrators need to clear the cache when new content is added, or install a management plugin like Varnish HTTP Purge, which resets the cache for any pages or posts that have been updated, and gives administrators a simple interface to clear the cache when theme or menu changes have been made.
High number of codes
You may have high traffic more if your blog has a high number of code and design elements.
For instance, if the front page of your blog calls upon 8 graphics to create the “look” of your blog’s design you should add this number to the various WordPress template files it takes to build your page. This includes at least the header, sidebar, footer, and post content area, creating four more “calls” to files on your site. That’s for 100 visitors, those files get loaded 1200 times, for 1000 visitors, those files are loaded 12000 times, increasing both bandwidth and server activity.
WordPress Plugins are also files that are “called” by your WordPress Theme. These plugins make queries to your database to generate the information on your blog. This means, the more WordPress Plugins, the more queries to your database. Combine all these access files and database queries with an exponential increase in visitors. You have a lot of demand on your site.
You can minimize the number of files accessed and the queries to your database during periods of heavy traffic by:
- Limiting the number of graphics on your blog. You may do this by editing the stylesheet and template files of your WordPress Theme.
- Turning off a few WordPress Plugins temporarily. just go through your list of WordPress Plugins to see if there are any listed that you could live without for a day or two.
Keep access to files and your database to a minimum as much as possible. Reactivate and restore these features after the heavy traffic volume has died down.
You might require a more powerful server.
Here are some steps to upgrade for a site that is having problems with high traffic. If you are having trouble with:
- Shared hosting: try upgrading to Virtual Dedicated Hosting.
- Virtual Dedicated Hosting: try upgrading to Dedicated Hosting.
- Dedicated Hosting: try upgrading to a higher-powered dedicated server.
- High-Powered Dedicated Hosting: talk to your hosting provider about multiple Load Balanced Servers.
In all of these cases, your server is only as capable as your network provider. If your provider does not provide the bandwidth you need, you may need to negotiate an increase, or find a different provider that can provide you with the bandwidth that your traffic requires.
Hope this article helped you, guys!