in Crash Course

Learn how your WordPress blog can weather a digg / slashdot / reddit / etc effect

In this article, we are going to cover one trick that is used in Web social circles to weather short-lived traffic storms. In most cases, servers collapse due to the server-side processing that needs to occur to produce the HTML that sent to the browser. Whether the server-side script is written in PHP, Ruby, Python, or Perl with a database back-end, this trick is effective and does the job. It gives you much needed breathing room to plan ahead should the spike continue for weeks.

In the case of a WordPress blog, say for example http://blog.unixy.net/2010/03/bargain-bin-fully-managed-dedicated-servers/, upon visiting the Bargain Bin blog link, the server where blog.unixy.net is hosted will need to perform several tasks to render the page and send it the HTML results back. The tasks consist of running PHP scripts, querying the database, and retrieving files from disk amongst other tasks. Under extended peak traffic periods, these tasks when repeated continuously overwhelm the server and cause it to slow down and sometimes to crash.

So, if all the server does is produce the HTML code and send it back to the browser, we might as well just generate the HTML ourselves once and instruct the server to send it instead, bypassing all of that heavy processing. So without further delay, here is how one can generate the HTML:

GET http://blog.unixy.net/2010/03/bargain-bin-fully-managed-dedicated-servers/ &> /tmp/bargain-bin.html

The GET command comes as part of the libwww-perl package, which is available for both Linux and Windows. Now that we obtained the HTML, we are going to add a .htaccess rule to temporarily redirect all requests to the article /2010/03/bargain-bin-fully-managed-dedicated-servers to bargain-bin.html. Be sure to move the file my-page-dugg.html to the HTML root folder. Here is the .htaccess rule:

RewriteEngine on

Redirect 302 /2010/03/bargain-bin-fully-managed-dedicated-servers /bargain-bin.html

Be sure to put the above rules before the WordPress rules. The 302 rule means that it is a temporary redirect. This is so it is SEO friendly and does not break your links as search engines see them.

I hope you enjoyed this short article. The above instructions can work for about any CMS or portal. Keep in mind that should you be one of our customers, we will be very happy to complete this workaround on your server for no extra charge.