Few days ago as I was happily chopping away on my duck taped Rails application I decided it was a good moment to measure up bottlenecks and optimize a bit. Here is overview of what I did. It consists of common sense actions that I picked up here and there, in my ongoing battle with slow applications.
Application main index page is loading in about 4.5 seconds, Apache Benchmark tool (just ‘ab’ from now on) measured speed of 5 pages/second.
Paging is a pet peeve of mine. As a user I hate it, as a developer I need it to make application work. Special annoyance is deciding how many items per page is enough. My rule of thumb is 20-25 items so the users doesn’t have to click pages like crazy (Deep down I am always wondering if anybody is even using paging).
One tweak I had implemented before performance tuning was using jquery.pageless plug-in. It helps in getting rid of paging altogether by loading content as it is needed. In this light I’ve reconsidered the number of items to preload. I opted out to have 6 elements per page (just one screen worth of data). If users wants more it is just a scroll away.
This reduced load time dramatically down to 1.5 second.