Discussion:
Improving performance for lots of comments
Roger Chen
2013-09-30 23:23:45 UTC
Permalink
Hi all,

One of my WordPress pages has 2,000+ comments and when I visit it, it can
take 5-6 seconds to load. Of course, this isn't a problem for visitors
because a cached version gets served, but it is still annoying to have to
wait that long for all of the comments to render. I don't want to break the
comments into pages either, since all of those comments are a huge SEO
boost.

I have removed cut down my comments template to the bare minimum, but the
comment markup loop still takes too long. I wish there were some way for
WordPress to automatically cache the markup for past comments so that every
time a new comment is posted, it only needs to generate markup for new
comments.

Does anyone have experience with something like this?

Roger
Casey Bisson
2013-10-01 01:08:38 UTC
Permalink
Roger,

I've faced similar problems elsewhere. The solution I used at the time was to capture the comment markup and save it as meta on the post. In most cases the template would fetch the markup from the post meta rather than generating it fresh.

Any time a comment was added or removed, etc, the cache was deleted and the list regenerated.

The performance improvement for posts with hundreds or thousands of comments was ten to 20 seconds.

Since then we've shifted to paged comments, though because of how the comment walker class works, we still suffer many of the performance affects related to iterating all the comments that we did previously.

Another important aspect to consider is gravatars. 1000 gravatars can take many tens of seconds to load in the browser. Lazy loading those has a huge performance effect.

--Casey Bisson
Post by Roger Chen
Hi all,
One of my WordPress pages has 2,000+ comments and when I visit it, it can
take 5-6 seconds to load. Of course, this isn't a problem for visitors
because a cached version gets served, but it is still annoying to have to
wait that long for all of the comments to render. I don't want to break the
comments into pages either, since all of those comments are a huge SEO
boost.
I have removed cut down my comments template to the bare minimum, but the
comment markup loop still takes too long. I wish there were some way for
WordPress to automatically cache the markup for past comments so that every
time a new comment is posted, it only needs to generate markup for new
comments.
Does anyone have experience with something like this?
Roger
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Roger Chen
2013-10-07 00:11:49 UTC
Permalink
Thanks Casey, your tips helped a lot.

I settled on storing the comment markup in APC via the WP Transients API
for all comments past the first hundred. Each comment was keyed
individually, since I had surrounding markup based on the comment's
location as well. Response times have gone from ~5500ms to ~1000ms for
logged-in users.

Roger
Post by Casey Bisson
Roger,
I've faced similar problems elsewhere. The solution I used at the time was
to capture the comment markup and save it as meta on the post. In most
cases the template would fetch the markup from the post meta rather than
generating it fresh.
Any time a comment was added or removed, etc, the cache was deleted and
the list regenerated.
The performance improvement for posts with hundreds or thousands of
comments was ten to 20 seconds.
Since then we've shifted to paged comments, though because of how the
comment walker class works, we still suffer many of the performance affects
related to iterating all the comments that we did previously.
Another important aspect to consider is gravatars. 1000 gravatars can take
many tens of seconds to load in the browser. Lazy loading those has a huge
performance effect.
--Casey Bisson
Post by Roger Chen
Hi all,
One of my WordPress pages has 2,000+ comments and when I visit it, it can
take 5-6 seconds to load. Of course, this isn't a problem for visitors
because a cached version gets served, but it is still annoying to have to
wait that long for all of the comments to render. I don't want to break
the
Post by Roger Chen
comments into pages either, since all of those comments are a huge SEO
boost.
I have removed cut down my comments template to the bare minimum, but the
comment markup loop still takes too long. I wish there were some way for
WordPress to automatically cache the markup for past comments so that
every
Post by Roger Chen
time a new comment is posted, it only needs to generate markup for new
comments.
Does anyone have experience with something like this?
Roger
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...