Engineering • December 2nd, 2008 • 3 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.

3 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. Gertha Schramek says:

    I would suggest putting them inside of an old pillowcase and tying a knot in the case and then putting them in your wash machine. Putting them inside the pillowcase reduces the noise level and keeps the shoe laces from becoming tangled in your machine. You can use any type of detergent (not bleach), I suggest Tide for the best results. Depending on how dirty they are you may want to add some detergent to them prior to putting them in the pillowcase/washer and let them presoak for a bit.

  3. advance email search says:

    Wow! danke! My bro always wanted to write in my site something like that. Can My bro take part of your post to my blog?

Leave a Reply

Categories

from heri.tumblr.com



Photos

samedi samedi samedi samedi soirée samedisoirée samedisoirée samedisoirée samediSénégalun soir d'été

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.