• 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.










December 14th, 2008 at 11:16 am
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.
August 29th, 2010 at 11:32 pm
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.
August 30th, 2010 at 7:31 pm
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?