A simple Rails performance tuning workflow

September 23 Bullet_white By Derek Bullet_white Comments Comments

I really like Dan Mange’s workflow for Rails performance tuning:

  1. Use curl for benchmarking. It’s good enough (and damn simple).
  2. Use the ruby-prof gem along with an optional request parameter so you can profile any action, any time.

Dan also does a solid job explaining CPU time and what if means for your Rails app. A snippet:

At CarePages we have an Apache log that logs the controller, action, and Rails runtime. We run a script that groups the runtimes by controller and action, and then calculates the total runtime for a controller/action divided by the total runtime for all requests. What we found the first time we did this was that one of our pages was taking nearly 40% of the overall CPU time. It wasn’t the slowest page, but it was the most frequently hit page. We had two other pages that were taking about 19% and 13% of the overall CPU time. This gave us a good place to start – if we could make the 40% page twice as fast, we would lower our overall CPU usage by 20%.

Get notified of new posts.

Once a month, we'll deliver a finely-curated selection of optimization tips to your inbox.

Comments

comments powered by Disqus