Thursday, September 18, 2008

have you ever measured your rails application performance?

Well, you have been developing rails applications for over a year or couple. You did every bit of it The Rails Way keeping it DRY, writing migrations, associating your models and built-in test cases. The app seems to work great on your local machine. But are you sure it does on the production server? Have you ever used any profiling or benchmarking tools to measure the performance of the apps? If not its time to use one and make sure your apps run faster not only during development but also in the production environment.

As there are many such tools that serve the purpose, the two head-to-head competitors, RPM from new relic and Five Runs from fiveruns , which are strongly backing the Rails framework to become enterprise ready, make a good choice.

Given the task to finetune a rails app, I preferred relic over fiveruns as it is very easy to get going. RPM Lite, a standard version of RPM is free as long as you want and you can always upgrade it to enjoy more featues. For a developer use, RPM Lite is enough.

RPM Lite is available as a plugin. I got the plug-in installation link through subscription at new relic, installed it and restarted my server.
Note: The plug-in installation creates a
config/newrelic.yml file. I didn't pay much attention to it. But it may contain some interesting configuration.


Now, whenever I made a request to the server, the relic plugin monitored my request and measured the time for processing my request. This is available at http://localhost:3000/newrelic.

Amazingly, relic tracked my request right from the controller to the model to the view.
1. It gave me an analysis of time spent in the controller, the model/db calls executed and to
render the results to my view to an accuracy of milli seconds.
2. It also produced a pie-chart of the processes involved.
3. It provided me with an sql view, where I could track the sql executed.
4. Number of such requests that could be server per second.
5. It also tracked AJAX requests.

From the analysis, I learnt that the app is spending most of the timein DB calls which I eventually reduced.
This way, I could make a better use of RPM and finetuned the app resulting in a notable performance boost. So, why not give it a try right now. I hope RPM will serve the purpose for you too.



No comments: