Ruby • December 2nd, 2008 • 4 comments

Factors of Memory consumption and Start-Up times of a Ruby And Rails application

While managing TechEntreprise, I found out that:

  • Routes.rb plays a significant role in the application’s startup times and also memory consumption. Dropping formatted routes (using named routes instead of mapped resources) shelled out 30Megs of RAM from every thin server instance, and the application was also significantly faster
  • Associations (has_many and belong_to), and number of models increases significantly the quantity of RAM needed. Interestingly, the thin/mongrel server doesn’t take up significant RAM resources at the beginning, but will grow as users request to use the model or resource. The latest update (rev #529 or so) introduced more associations, which were the core of the new product feature, and the thin server all went beyond the memory amount limit (120M), and were restarted automatically by monit.

In the last case, users who connected to the website restarted the thin servers, since monit was alerted, and got average time serving of 20 seconds or so, with visible degraded performance.

The lesson here is: when your application grows, be mean and lean, stay DRY, and consider existing associations before introducing new features.

4 responses to “Factors of Memory consumption and Start-Up times of a Ruby And Rails application”

  1. Pierre Phaneuf says:

    Something I found to help, but that I don’t know if it translates well to Thin/Mongrel, is to do some coarse routing in the HTTP front-end/reverse-proxy, sending the request to multiple WSGI back-ends. You have to share less data in memory (memcache comes handy to compensate there), but you can manage things on a much finer grain, and the HTTP front-ends tend to do a much better job of routing quickly. You can run more instances of the busier handlers without wasting memory used by the less busy handlers, for example.

  2. Mindi Mckamey says:

    Despite a pedestrian 5-5 record in the UFC, the Johnsburg, Ill., native has still managed to pick up three “Fight of the Night” honors for his wild-haired fighting style.

  3. Von Woodford says:

    Rampage has also stated in interviews that he might consider the UFC if he knew they were interested in promoting him rather than just trying to match him up with Liddell right away.

  4. windows registry cleaner says:

    I am shocked at the things I overlooked before I read this post. Thanks for the great information.

Leave a Reply

Recent Projects

Categories

Recent Comments

Recent Posts

from heri.tumblr.com

Design

Friends and People I like reading

Marketing

Technology

World



Photos

snapshotGriot AfriqueTigre; Festival Nuits d'AfriqueSalam, Festival des nuits d'afriqueart anywherephoto.jpgphoto.jpgphoto.jpgmontreal startupdrinksNil Bleu

See more pictures

Heri is also at

Heri does not use Instant Messenging or other communications means that disrupts workflows.


© 2007 2008 Heri Rakotomalala
Photographs and Screenshots are under Creative Commons. Attribution-NonCommercial-ShareAlike 2.0
Screenshots, logos, videos, and trademarks showcased on this blog are the property of their respective owners.