How To Improve Performance of Highly Commented WordPress Blogs
By Angsuman Chakraborty, Gaea News NetworkWednesday, April 26, 2006
Most of highly trafficked and highly commented wordpress blogs rely upon some smart caching solution or another. However it may not be enough to prevent slowing down your server if your post(s) are heavily commented upon. This is because smart caching solutions re-create the cache whenever a new comment is posted. Here is a simple solution in three steps.
Steps:
- Install (and activate) Wp-Cache 2 plugin. I have excellent experience with it for over a year.
- Modify wp-cache-phase2.php (one of the plugin files) to comment / delete the line:
add_action('comment_post', 'wp_cache_get_postid_from_comment', 0);
- Set the cache expiration time to 2 hours or more. This can easily handle a slashdot effect without breaking a sweat.
The change in step 2 ensures that the pages are not regenerated everytime a new comment is posted. They are however regenerated after the expiration of cache. This time lag saves an enormous amount of sql query when a post is heavily commented.
September 28, 2010: 4:29 pm
What goes around comes around. Your good blog is attracting only good visitors. |
![]() Tejas Suthar |
February 14, 2010: 11:25 pm
Hello Author, |
May 2, 2007: 10:58 am
You can always buy a bigger and better server / load balance it, also use memcached, eAccelerator etc. Each of them works in different ways to improve performance. You may want to read this article for details: |
May 1, 2007: 8:34 am
Whilst I don’t have a high volume of comments across all posts on my blog, there are 2 posts which have a combined total of more than 1200 comments and this seems to be bogging down the site, or at least the loading of those 2 pages. I installed wp-cache but since installing I have also started getting internal server 500 errors for one of the posts. Is your solution the only way of of speeding up these pages? |
March 20, 2007: 8:18 pm
Would you have any tips for configuring WP-Cache 2 with interactive plugins like GamerZ PostRatings, or comment karma? I’ve tried using the mfunc mods in my designs, but they never seem to work… do you know if a mfunc has to be within a if function_exists call? This is driving me nuts. Eric |
January 1, 2007: 12:23 am
[...] I recommend it over external caching engines like eAccelerator because it is senstive to changes in WordPress content and will automatically refresh the cache. However it has a downside. On highly commented sites the effects of caching is negated because of frequent cache refreshes. This can be addressed by this tip: How to improve performance of highly commented WordPress blogs [...] |
November 18, 2006: 12:48 pm
[...] Since the machine was limited by CPU, I decided to fire up DTrace to see where the httpd process was spending it’s time. The DTrace results indicated that Apache was spending a considerable amount of time compiling PHP pages, and issuing queries to the back-end database. Since I only update my blog a few times each week, I started to wonder if there was a way to turn the pages I created in Wordpress into static content. After reading through a variety of wordpress resources, I came across the wordpress cache #2. This super useful plugin will create a static represetnation of each dynamically generated page, and serve that file instead of the page that wordpress woudl dynamically generate. Once I got wp-cache2 installed, the results were right on par with what I orginally thought they should be: [...] |
November 17, 2006: 10:21 pm
If this tip doesn’t help then you are pretty much due for a dedicated server |
November 17, 2006: 2:41 pm
Thanks for the tips. I am not sure this will help because this looks like suitable for blogs with a lot of comments. My problem is a little different, not so much on comments. My blog is having too many visitors, thus have too many processes running at the same time. How to optimize this? |
May 4, 2006: 2:44 pm
[...] Falls Ihre Seite laufend mit neuen Kommentaren �bersch�ttet wird, so sollten Sie auf eine Installation der Caching-Funktion verzichten oder diese zumindest nicht im “Auslieferzustand” einsetzen. Da die Cache-Dateien in diesem Fall eine zu kurze G�ltigkeitsdauer haben, k�nnte die Installation Ihren Server mit den zus�tzlichen Aufgaben �berlasten (oder zumindest nicht entlasten). Sollten Sie trotzdem nicht auch ein Caching verzichten wollen, dann k�nnen Sie mit dem folgenden kleinen Hack f�r Abhilfe sorgen. Damit wird die Aufbereitung der Caching-Seite nicht von neuen Beitr�gen oder Kommentaren abh�ngig gemacht, sondern erfolgt zeitgesteuert. Der Nachteil: neue Kommentare oder Beitr�ge werden nicht sofort, sondern erst nach der zeitbasierten L�schung des Caches sichtbar. [...] |
April 29, 2006: 7:27 am
It’s not a terrible thing, but it’s not right for every site. For sites where the community and discussion aspect is an important part of why people visit, changing the situation from comments-appear-instantly to comments-appear-after-a-pause can turn people off and eliminate one of the reasons that they came and visited in the first place. Of course, having a pause before comments appear is better than having a site that doesn’t work. But not everybody who is looking to improve WP’s performance is at a place where their site is crashing constantly. My site for instance is still chugging along fine performance-wise, but I’ve been warned by my Web host that it’s starting to take up more server resources than they’re comfortable with, so I’m looking at ways to improve performance. Still, because my site visitors enjoy using the comments section to talk to one another more or less in real time — and because, I suspect, a long pause after commenting would result in fewer visits on their part (and thus less revenue to me) I wouldn’t implement a technique like yours except as a last resort (i.e. if my Web host got fed up and was threatening to shut me down). Still, I’m sure there are plenty of blogs for whom discussion and comments are not key features of the site, and the technique you outline would be very helpful to them. jf |
April 28, 2006: 9:23 pm
The new comments are published as soon as the cache expires. So if your cache is set to 30 minutes then you get to see the new comments every 30 minutes instead of instantly. Probably this is what was not clear to Brian as I am still trying to understand why he thinks it would be such a bad thing. |
April 28, 2006: 2:36 pm
Sorry to be a little dense, but does this hack actually make the comments not appear on individual post pages until the cache expires? Or do the number of comments indicated on the main page simply not update to match the actual number of comments visible on individual comment pages? jf |
April 28, 2006: 12:17 pm
> My feeling is that the number of comments on a weblog is going to be very low. I used this technique for a limited time on this blog with good results. > But, even if somehow the volume of comments becomes a problem, wouldn’t a better solution be to move the comments onto a seperate page? How are you going to do that within WordPress framework? > Anyway, I just think that there are so many other possibilities to improve performance Please let me know how you plan to optimize performance of a heavily commented site without slowing down page re-generation after comments? |
![]() Brian |
April 27, 2006: 10:53 pm
Have you implemented this on a public site that I can see it in action on? I noticed when I posted that you don’t use it on this one. I am really curious about the type of site you feel this would be helpful on. My feeling is that the number of comments on a weblog is going to be very low. But, even if somehow the volume of comments becomes a problem, wouldn’t a better solution be to move the comments onto a seperate page? This would get rid of most of the read-only load as well as the read-write load due to comments because you are only sending that page to the small fraction of people that care about the comments in the first place. Anyway, I just think that there are so many other possibilities to improve performance before taking a step that has such a negative impact on the user experience. |
April 27, 2006: 12:51 pm
When the choice is between providing instant gratification versus making the site available, isn’t the solution clear? I don’t think expecting comments to appear immediately is something which users have come to expect as many sites today have manual or semi-manual moderation policy. A clear statement explaining the situation should address the expectations. |
![]() Brian |
April 27, 2006: 10:49 am
People like instant gratification. If somebody makes a comment on a website, they expect it to show up immediately. Otherwise, the commentor will be discouraged from posting a comment in the future. Because of this, I think that another solution is needed. |
funny pictures