Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails gems/tools for performance benchmarking?

I'm looking for tools to monitor/test performance in rails, and I'm not having much luck finding anything particularly effective. I've read the rails 'performance' guide, but I use RSpec instead of Rake:Test, so I'm not particularly keen to use the rake:test framework.

So, what do folks use for performance testing in rails apart from the rake:test benchmarker? Any suggestions appreciated

like image 997
PlankTon Avatar asked Jan 27 '11 11:01

PlankTon


2 Answers

Performance benchmarking is one of those things that you'll get different opinions about depending on who you ask. One thing I hear over and over is that you shouldn't obsess over performance early on. I'm not sure where you're at with your application, but this could be something to consider. After developing a rather large application, I can honestly say I agree with them. It's better to use good practice when developing and wait to do performance tuning at a later time. Best practices include things like indexing database columns.

For performance monitoring of live Rails applications, New Relic is one of the best tools out there*. The free plan is a little limited as it only provides 30 minutes of historical data, but the information it collects is priceless. Some of the cloud hosts like Heroku and Engine Yard are offering free bronze plan upgrades, which stores a week of data. Once you have information about your application, you can make educated decisions about where to focus your time.

* My opinion

like image 177
Peter Brown Avatar answered Oct 06 '22 22:10

Peter Brown


When your app needs some performance testing, the default TestUnit based performance benchmarking tests are a great start. However, you shouldn't stop there, and should consider using a variety of tools based on the nature of your application.

For example, analyzing production logs using a tool like the request-log-analyzer is a great way to identify the real performance bottlenecks. Bullet is another great tool you can run in your development environment to identify performance inefficiencies in your database calls. For low level benchmarking, rails also gives you the benchmark helper methods in models, controllers and views. This can be handy if you are focusing on tuning some specific part of your application.

It is also worth noting that rspec is not the best tool for benchmarking performance (to date). In my opinion, trying to assert things like it should_take_less_than 50 is stretching the idea of performance testing and trying to force it into the concept of BDD. Performance is less often about absolute expectations and more about identifying the slowest parts of your app and making them faster.

There are many online resources on the topic. I've found these railscasts to be a great starting point:

  • http://railscasts.com/episodes/368-miniprofiler (free)
  • http://railscasts.com/episodes/411-performance-testing (pro, requires subscription)
like image 23
Shyam Habarakada Avatar answered Oct 06 '22 21:10

Shyam Habarakada