Home arrow Ruby-on-Rails arrow Performance Optimization

Performance Optimization

If you've had a Ruby on Rails application up and running for a while, you may notice that it's not running as well as you'd like. This is when optimizing its performance can make a difference. This six-part article series will show you how. It is excerpted from chapter 13 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
December 01, 2010
  1. · Performance Optimization
  2. · Measuring Performance

print this article

Performance Optimization
(Page 1 of 2 )

We now have a working application, and people are already rambling in to shop at the Emporium online store. While George is very happy that the money is flowing in, he has noticed that the site is behaving less responsively lately.

Here, we will look at techniques for optimizing the application. This chapter is not about specific functionality in the application, so we won’t tell it in the form of user stories. Neither do we use TDD here, since we’re not really developing anything.

Performance and Scaling

Recently, the terms performance and scaling have been used interchangeably within the context of web development. Actually, they don’t mean the same thing.

Performance means how many concurrent users can use a web application and still consider it working fast enough. The “fast enough” part depends on the application and its use.

Scaling, on the other hand, is a totally different beast. To paraphrase the creator of Mongrel, Zed Shaw (http://www.oreillynet.com/ruby/blog/2006/05/ post.html), scaling should be more analogous to “resource-expandable,” meaning that you can start with a moderate hardware and software stack, and easily expand it so that the application is snappy, even if it gets Slashdotted.

An often-heard argument against Rails is that it doesn’t scale. People stating this often assume that scaling and performance are the same thing, and really mean that Rails is slow. Although Ruby as an interpreted, dynamic language is not among the fastest programming languages, that doesn’t mean Rails as a web framework is slow. The fact that 37signals ran Basecamp with up to tens of thousands of customers on a single box without any caching whatsoever should be enough to prove that Rails is fast enough for most uses.

There is nothing in Rails that would make it inherently hard to scale (scale as in being easily “resource-expandable”)—quite the contrary. Rails uses shared nothing architecture similar to that used by many very high-traffic websites like Google and Livejournal. Shared nothing is a distributed architecture consisting of independent nodes without a single point of contention. In Rails, this means that you can scale very easily by adding new application servers. If the pages are not rendered fast enough by one server, add another server next to it. Load balance requests between the two, and you have roughly doubled the performance of the application (depending on the database performance).

blog comments powered by Disqus

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials