Last week my keyboard prank post was promoted to the front page of Digg and within minutes my WordPress blog was down for the count. Being slightly embarrassed I tried get my site back online and along the way found several things you can do to prevent this from happening to you!
NOTE:
I do not claim to be an expert on this subject. If you have more insight or suggestions please post a comment here.
MySql
Most times it’s the MySql database that’s the problem. All your blog entries are stored, managed and retrieved from a MySql database, and, by default MySql doesn’t allow more than 100 connections at a given time. So if you’re getting pounded by the entire world, most of your viewers will see an error page
Luckily there is an easy solution (if you manage your own server): just increase the number of connections MySql supports. Open your MySql configuration file, in my case it was at /etc/my.cnf, and set ‘max_connections’ to any number you want; I set it to 250. Now don’t forget to restart MySql after this change.
WP-Cache
MySql is only part of the issue — why abuse your database server if you don’t have to? WP-Cache is a WordPress plugin that caches your posts to static HTML files to save your database and server cycles.
This saves your MySql server by keeping the number of connections to a minimum. Also since WordPress is written in PHP, which is an interpreted language that must be parsed each time a page is requested, caching the pages as HTML saves your web server cycles and speeds up the load time for your viewers.
By default the cache is used for an hour until it’s expired and refreshed with new content. Since I wanted to view the recent comments quicker than that I changed the expiration time to 4 minutes (or 240 seconds). To change this click Options > WP-Cache and change the expire time value and then click ‘Change Expiration’. Be sure to read the WP-Cache instructions on how to install and configure it.
Mirroring
These steps are all fine and good, but what if your server can’t handle the traffic or you don’t have the administrative rights to make the necessary optimizations? At this point you’ll want to mirror blog post before it gets submitted to Digg or Slashdot. The reason I stress this is if you wait until your site is down, it’s too late.
Mirroring your content only takes a single click with the Coral Content Distribution Network. Coral works like a P2P network and as soon as your link is submitted on their website, it’s mirrored around the world across 260+ servers. To start, go to their website and enter your URL in the form (under Using Coral) and click ‘Go’. This will open a new window and show you your mirrored page (this may take a minute).
It’s important to note that Coral does have a bandwidth limit on the URLs it mirrors, so it might be a good idea to create a couple more mirrors through Coral. You should be able to do this by adding a unique parameter to your URL; I did it this way:
- http://blog.mozmonkey.com.nyud.net:8090/2006/april_fools_hack/
- http://blog.mozmonkey.com.nyud.net:8090/2006/april_fools_hack/?mirror2
- http://blog.mozmonkey.com.nyud.net:8090/2006/april_fools_hack/?mirror3
Now, when you post to Digg or another high traffic website you can include these mirror URLs as the one of the first comments.
Apache
If you’re running your site through Apache you probably wont need to tweak it much — the only thing I did was set MaxClients to the max (256). For more information about Apache optimizations checkout the Apache Performance Notes. This article has some simple changes you can make to help squeeze the most out of Apache.
Advanced Options
If you want to know more advanced optimizations checkout High Performance WordPress. This article goes into great detail about how WordPress works and many more things you can do to optimize it.
Add to: Del.icio.us | Digg it | Slashdot | Y! MyWeb

33 Responses
Optimizing Wordpress Cache - Aaron’s Webmaster Workshop Says:
May 11th, 2006 at 5:47 am
[…] Jeremy Gillick (software engineer and cool prankster) says: Last week my keyboard prank post was promoted to the front page of Digg and within minutes my WordPress blog was down for the count. Being slightly embarrassed I tried get my site back online and along the way found several things you can do to prevent this from happening to you! […]
Phuket Thailand Says:
December 15th, 2006 at 7:22 pm
Phuket, travel, thailand, tsunami, hotel, resort, holiday, phuket hotel thailand hotels news online.
earn cash make money online Says:
December 27th, 2006 at 10:33 am
Happy New Year To ALL
Jimmy Dushku Says:
January 1st, 2007 at 6:32 pm
That was interesting. Check out Jimmy Dushku’s site at http://www.JimmyDushku.com
penis enlargement Says:
January 7th, 2007 at 9:23 pm
Great post. I´ll think about that.
Interesting Links (2) at kyantonius.com - daily babblings! Says:
January 31st, 2007 at 1:59 am
[…] Optimizing WordPress for High Volume Traffic […]
Alexander Says:
February 18th, 2007 at 1:22 pm
Hey! Thank you very much! Comes in handy for me!
RomiSatriaWahono.Net » Optimisasi Wordpress di Server Traffic Tinggi Says:
February 18th, 2007 at 11:08 pm
[…] http://blog.mozmonkey.com/2006/optimizing-wordpress-for-high-volume-traffic/ […]
Tim B. Miller Says:
February 19th, 2007 at 2:15 pm
Thanks Jeremy,
Good advice thank you for that, I just might need it someday.
zane Says:
March 15th, 2007 at 8:58 pm
Cool site. Keep posting. A++++
Why My Wordpress Site Is So Much Faster Than Yours by Elliott Back Says:
April 15th, 2007 at 4:56 pm
[…] Optimizing Wordpress for High Volume Traffic […]
Good List Of WordPress Optimisation Links | Connected Internet Says:
April 19th, 2007 at 5:11 pm
[…] Optimizing Wordpress for High Volume Traffic […]
David Bradley Says:
May 23rd, 2007 at 9:11 am
the wp cache script saved Sciencetext from a major drubbing this week. For some reason a fairly obvious post about how to use your GMail account as a virtual hard drive got Stumbled. Amazing how many people hit the site all at once…it would have pushed us over our CPU allowance very quickly indeed without wp-cache
db
优化 wordpress 以适应高流量 at ︻┳═一 [zsk.akaka.com.cn] Says:
June 20th, 2007 at 3:11 pm
[…] 原文:mozmonkey.com 译者:peterzsk 译文原地址:http://zsk.akaka.com.cn/2007/06/high-traffic-for-wordpress/ 采用CC创作共用协议,转载可保留以上信息并。 […]
master Says:
July 21st, 2007 at 12:18 am
博客
Virtual Hosting » WordPress on Speed: 17 Tweaks to Accelerate your WP Says:
September 17th, 2007 at 5:14 am
[…] mirroring. You can keep your WordPress blog from going offline by employing mirroring. Mirroring your content is very simple’ just sign up for a system like Corel Content […]
estetik Says:
December 6th, 2007 at 10:52 am
Very good information. I also installed wordpress but later I left it as you said mysql has many limitations.
paul Says:
December 15th, 2007 at 7:24 pm
it’s painful to get to know the limitations of your applications and servers. there are some other things you can do to help Wordpress move faster. One is to utilize a php accelerator. it’s a little involved for the novice, but really helps. another thing you can do is to make sure mysql is caching. that will help too. good post.
Value CDN Says:
December 29th, 2007 at 12:09 pm
You can also outsource to low cost content delivery networks (CDN). More SEO friendly and sometimes with better performance than Coral.
estetikameliyat Says:
January 2nd, 2008 at 4:56 am
Yes wordpress is a very useful blogging software however it has some limitations and most important is it is slower than classical html pages.
haber Says:
January 30th, 2008 at 8:10 am
and servers. there are some other things you can do to help Wordpress move faster. One is to utilize a php accelerator.
Blackpool Self Catering Apartments Says:
February 25th, 2008 at 8:15 am
Nice Tip. Thats very helpful, I wondered why my views were getting error pages.
Thanks
Wordpress Performance: Why My Site Is So Much Faster Than Yours (转) | 不止是边缘 Says:
March 17th, 2008 at 7:04 am
[…] Optimizing Wordpress for High Volume Traffic […]
Bobbo Gus Says:
April 22nd, 2008 at 10:40 am
I have been using the hell out of WP-Cache… what a life saver! Great advise… thanks!
K Stone Says:
April 22nd, 2008 at 5:00 pm
is there any downside to increasing the max users for mysql database?
thanks for this article.
Jeremy Gillick Says:
April 22nd, 2008 at 10:33 pm
@K Stone
I’m not really sure. If you increased it too much it could use all your ram or CPU cycles. I’m not sure what the magic number is.
Here’s some more good information on the subject:
http://www.itslot.com/calculate_mysql_memory
Mine is set to 250, which has worked well for me.
Bill McIntosh Says:
May 1st, 2008 at 9:05 pm
Thanks for the info.
Do you know what the Coral bandwidth limit on the URLs it mirrors is?
IndoProTech.com Says:
July 2nd, 2008 at 12:12 am
[…] Optimizing Wordpress for High Volume Traffic […]
优化wordpress以适应高流量 : 行路男 Says:
July 4th, 2008 at 8:21 am
[…] 原文:mozmonkey.com 译者:peterzsk 译文原地址:http://zsk.akaka.com.cn/2007/06/high-traffic-for-wordpress/ 采用CC创作共用协议,转载可保留以上信息并<署名、非商业和保持一致>。 […]
Juni Says:
July 11th, 2008 at 12:50 am
I also use wordpress and this information is very useful. I don’t add my site on any social bookmark yet but maybe in the future.. who knows…
lucky casino world online Says:
July 19th, 2008 at 8:28 pm
lucky casino world online…
worthy reticulating drastic …
Niyaz Says:
July 21st, 2008 at 7:03 am
That really helped friend.. its very informative.Thank you
Steve Wilcox Says:
July 23rd, 2008 at 1:23 pm
By default the cache is used for an hour until it’s expired and refreshed with new content. I was not aware of this. We are now optimizing our site accordingly. Thanks!