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










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.
February 9th, 2010 at 7:39 pm
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.
February 10th, 2010 at 11:53 pm
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.
March 3rd, 2010 at 4:06 am
I am shocked at the things I overlooked before I read this post. Thanks for the great information.