« One year ago today. | Main | Java is a minivan. »

Fixing Roller.



A number of people have asked how Freeroller suddenly became so fast and so stable. The answer is Roller 0.9.8. Freeroller had been running Roller 0.9.7, which had a history of performance and stability problems from the start.

The first problem we experienced with Roller 0.9.7 wasn't noticed by the users, but our gracious hosts at The Javalobby noticed an unusually high load on their server coming from the Roller and MYSQL processes. Later, as the number of bloggers blogging and readers visiting the site grew, users started to notice unpredictable behavior. Spurious 404 errors, sluggish performance, and frequent downtime started to irritate everybody.

Roller 0.9.8 seems to have resolved all of these problems. Let's take a look at the changes made since Roller the initial 0.9.7 release starting with the changes that were applied to Freeroller before the Roller 0.9.8 upgrade:

  • Caching weblog update times. Because Roller uses page caching, most content is served out of the page cache and for most requests there is almost no need to hit the database. For most requests we only hit the database to bump up hit counters and to determine last-update-time for RSS newsfeeds. Still, Roller was killing MYSQL and the load from Roller and MYSQL was dragging the Javalobby server down. Since RSS newsfeeds account for more than 60% of all traffic, I decided to cache those last-update-times. Javalobby noticed an improvement in load, but load was still a little high.
  • The Open session in view pattern. With new users signing up every day and a number of more high-profile bloggers starting to draw in the hits, Freeroller really started to drag and users started to notice. The Roller development team started to wonder "what have we done wrong?" We eventually concluded that Roller uses too many persistence sessions, which roughly correspond to database connections, per request. Lance implemented the open session in view pattern in the Castor and the Hibernate persistence implementations in the Roller main branch. I backported the changes to the Roller 0.9.7 branch and deployed them to Freeroller only to find a minimal performance increase.
  • OSCache 2.0-beta upgrade. Around that time, the OSCache team relased a beta of OSCache 2.0 and Hani told me that the old OSCache was rubbish and had a terrible memory leak, so I switched Roller and Freeroller over to the new OSCache, configured it for memory caching plus unlimited disk cache, and noticed a pretty big leap in performance and decrease in system load. Still, the stability was poor and spurious 404s continued.

Those changes were important changes, but they did not fix the performance and stability problems. Now, let's move on to the changes that were added by the Roller 0.9.8 upgrade:

  • Numerous small fixes. While I was fussing with Freeroller and Roller 0.9.7, Lance and Min were looking for further performance improvements in the Roller 0.9.8 branch. Min fixed the Roller calendar control to keep it from hammering the database as it use to. They both worked to change the persistence layer interfaces to return lists instead of arrays, since both Castor and Hibernate return lists, list to array conversions are just silly in this case.
  • Database indices. At some point during Roller 0.9.8 development somebody (Jim Smart?) contributed a patch for the Roller database creation script and added indices where indices were missing. I didn't think much of it at the time, but this was a pretty significant change.
  • Hibernate/JCS caching. Freeroller was getting worse and worse, even causing Freeroller founder Anthony Eden to leave and, believe it or not, even causing the Hibernate team to feel the heat. Some were suggestingthat perhaps Hibernate did not scale. Gavin King stopped by the Roller dev-list and suggested that we try using proxies and JCS caching. I didn't get far with proxies, but it was easy to turn on JCS caching. Unfortunately, JCS caching by itself didn't seem to help much.

So, what change made the big difference in performance? It can't have been only update-time caching, open session in view, and OSCache 2.0 changes because they were all in place before the Roller 0.9.8 upgrade. It can't have been Hiberate/JCS caching because stress testing showed that JCS actually slowed down the system a bit. All of these fixes played a part in the performance improvements, but because of the greatly reduced load on MYSQL I think the database indices made the biggest difference.

Comments:

Lots of lessons learned! Keep up the good work.

Posted by Jevon on September 22, 2003 at 12:22 PM EDT #

Database indices can make an absolutely absurd amount of difference in terms of performance, just ask any DBA. I don't know if MySQL has a similar feature, but in the Oracle world, it's easy to see how indices can make a big difference in database performance because Oracle is happy to show the method it will use to construct and execute a query. In Oracle the magic words to avoid are "full table scan" (if I remember correctly). Congratulations on getting the problems ironed out in any case.

Posted by Rafe on September 22, 2003 at 01:20 PM EDT #

Thanks for the great example of how sometimes problems with functional requirements like performance can be caused by things totally outside our code base, like tuning the database. Sometimes we forget that there's lots of moving pieces and getting more and more clever with our application to try to squeak out performance is time wasted compared to looking at the bigger picture.

Posted by Jason Carreira on September 22, 2003 at 02:24 PM EDT #

I think this actually highlights a very common real-world problem. There is no silver bullet. Sure, it'd be nice if our apps were perfect and when performance is bad, it's a matter of finding the bad couple of lines to fix. Realistically though, it's often very many different things, and each little fix improves the situation a bit. Once you've addressed enough performance-impacting problems, you realise you've come a long way, even if any particular fix didn't contribute a huge amount.

Posted by Hani Suleiman on September 22, 2003 at 04:15 PM EDT #

Persistance pays off. Way to go! Interesting read of how the problem was actually debugged! Thanks

Posted by Arjun Ram on September 22, 2003 at 07:02 PM EDT #

[Trackback] Roller 0.9.8 is getting some very positive feedback and the changes are very impressive to read about in Dave Johnson's Blogging Roller blog. [Roller, 310 characters]

Posted by working on the future of solidarity on September 23, 2003 at 04:19 AM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« One year ago today. | Main | Java is a minivan. »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Roller, some may be related to this entry.