Between-request Garbage Collection using Passenger
        Posted  
        
            by 
                raphaelcm
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by raphaelcm
        
        
        
        Published on 2012-06-07T18:59:22Z
        Indexed on 
            2012/06/07
            22:41 UTC
        
        
        Read the original article
        Hit count: 260
        
We're using Rails 3.0.7 and REE 1.8.7. Long-term, we will be upgrading, but at the moment it's not feasible.
Following the advice of several blog posts, we've been tuning our GC, and have settings that work pretty well. But we would really like to run GC outside of the request-response cycle.
I've tried patching Passenger per this post, and using the code supplied in this SO question.
In both cases, GC does indeed happen between requests. However, every time the between-request GC happens, I see a bunch of this:
MONGODB [INFO] Connecting...
MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
MONGODB admin['$cmd'].find({:ismaster=>1}).limit(-1)
Starting the New Relic Agent.
Installed New Relic Browser Monitoring middleware
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  RefinerySetting Load (0.0ms)  SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`scoping` = 'pages' AND `refinery_settings`.`name` = 'use_marketable_urls' LIMIT 1
  SQL (0.0ms)  BEGIN
  RefinerySetting Load (0.0ms)  SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`id` = 1 LIMIT 1
  AREL (0.0ms)  UPDATE `refinery_settings` SET `value` = '--- \"false\"\n', `callback_proc_as_string` = NULL WHERE `refinery_settings`.`id` = 1
  SQL (0.0ms)  SHOW TABLES
  RefinerySetting Load (0.0ms)  SELECT `refinery_settings`.* FROM `refinery_settings`
  SQL (0.0ms)  COMMIT
  SQL (0.0ms)  SHOW TABLES
  RefinerySetting Load (4.0ms)  SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`scoping` IS NULL AND `refinery_settings`.`name` = 'user_image_sizes' LIMIT 1
  SQL (0.0ms)  BEGIN
  RefinerySetting Load (0.0ms)  SELECT `refinery_settings`.* FROM `refinery_settings` WHERE `refinery_settings`.`id` = 17 LIMIT 1
  AREL (0.0ms)  UPDATE `refinery_settings` SET `value` = '--- \n:small: 120x120>\n:medium: 280x280>\n:large: 580x580>\n', `callback_proc_as_string` = NULL WHERE `refinery_settings`.`id` = 17
  SQL (0.0ms)  SHOW TABLES
  RefinerySetting Load (0.0ms)  SELECT `refinery_settings`.* FROM `refinery_settings`
  SQL (0.0ms)  COMMIT
******** Engine Extend: app/helpers/blog_posts_helper
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  SQL (4.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
******** Engine Extend: app/models/user
  SQL (0.0ms)  describe `roles_users`
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  SQL (4.0ms)  describe `roles_users`
  SQL (0.0ms)  SHOW TABLES
  SQL (4.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  SQL (0.0ms)  SHOW TABLES
  (etc, etc, etc)
Which is what happens when rails "loads the world" when the app starts up. Basically, GC.start is re-loading the app for some reason.
Because of this, between-request GC is much slower than inline GC. Is there a way around this? I would love to have snappy, between-request GC if possible.
Thanks.
© Stack Overflow or respective owner