Site Notes

Site Speedup

By Ryan McGreal
Published August 16, 2010

I was in Gatineau Park during the crucial week leading up to the Pan Am Stadium vote with only limited internet access, but it was exciting - and sometimes harrowing - watching from a distance as the debate swung first one way and then the other.

I was dismayed, however, to discover that RTH visitors were experiencing slowdowns and timeouts on the day of the vote. At the most crucial moment in the whole enterprise, the website was failing under the heavy traffic coming our way.

Investigating it afterward, we discovered that the cause was actually a computationally expensive database query to generate the comments for each article and blog entry.

Because there were so many comments on each page, and because so many page requests were coming in, the server got bogged down trying to execute the slow comment queries and the result was poor response times and even failed page loads.

The site wasn't optimized to assemble the page content quickly enough, and the spike in both comments and traffic revealed this bottleneck in the worst way possible.

Since then, we've 'tuned' the database with better indexing on key look-up fields so that the comment query now runs a couple of orders of magnitude faster. Page loads on articles with lots of comments are already noticeably faster, and the site should be able to handle heavy traffic much better in future.

I'm really sorry for the inconvenience, and I promise that we'll take a more proactive approach to discovering other potential bottlenecks and alleviating them before the next spike in traffic.

Ryan McGreal, the editor of Raise the Hammer, lives in Hamilton with his family and works as a programmer, writer and consultant. Ryan volunteers with Hamilton Light Rail, a citizen group dedicated to bringing light rail transit to Hamilton. Ryan writes a city affairs column in Hamilton Magazine, and several of his articles have been published in the Hamilton Spectator. He also maintains a personal website and has been known to post passing thoughts on Twitter @RyanMcGreal. Recently, he took the plunge and finally joined Facebook.

6 Comments

View Comments: Nested | Flat

Read Comments

[ - ]

By rayfullerton (registered) | Posted August 16, 2010 at 14:37:33

MInor issue Ryan re: slowdowns, THANKS for all your work in keeping RTH a vital city blog!

Permalink | Context

[ - ]

By d.knox (registered) | Posted August 16, 2010 at 16:48:30

I willingly suffered the slowdowns because this was still the most informative, interesting site covering the issue.

Permalink | Context

[ - ]

By jasonaallen (registered) - website | Posted August 16, 2010 at 18:38:24

I would have to say occasional slowdowns are vastly preferable to RTH having Way Too Much capacity, all the time, if you catch my drift. This is a good problem to have, kudos for addressing it right away.

Permalink | Context

[ - ]

By jason (registered) | Posted August 16, 2010 at 19:11:14

Welcome back Ryan. It was a pretty slow couple weeks around here. You didn't miss much.

Permalink | Context

[ - ]

By JoeyColeman (registered) - website | Posted August 16, 2010 at 22:18:05

You sure it was your proximity to Parliament Hill that was the cause?

Permalink | Context

[ - ]

By Undustrial (registered) - website | Posted August 17, 2010 at 14:25:06

Good job - I never would have thought to look for a database query - probably would have done something a lot more expensive.

In any case, the fact that we're having slowdowns because of massive numbers of hits and topics getting 50+ comments a day is really kinda rad.

Permalink | Context

View Comments: Nested | Flat

Post a Comment

You must be logged in to comment.

Events Calendar

Recent Articles

Article Archives

Blog Archives

Site Tools

Feeds