Ruby GC Tuning – try some

I upgraded my versions of Phusion Passenger and Ruby Enterprise Edition last night.

This morning, I noticed that Nagios was alerting me that the load average on one of my machines was in the warning range.

Turns out that on one of my virtual machines, I forgot to configure Apache to use my ruby-wrapper script that sets environment variables for garbage collector tuning. Current versions of Ruby Enterprise Edition include the patches that support these tuning options. I knew that the tuning made a big difference but wow – check this out.

These are identical virtual machines on the same physical box that are receiving the same amount of traffic via round-robin load balancing. You can clearly see the ledge on Wednesday night when I performed the upgrade.


I haven’t experimented with the settings that we are using at all. I’m just using Twitter’s, because they were the first examples that were published and they made sense to me. An explanation of the options is here: http://railsbench.rubyforge.org/svn/tags/railsbench-0.8.3/GCPATCH

Here is my ruby-wrapper script:

#!/bin/sh

export RUBY_HEAP_MIN_SLOTS=500000 
export RUBY_HEAP_SLOTS_INCREMENT=250000 
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 
export RUBY_GC_MALLOC_LIMIT=50000000 

exec "/opt/ruby-enterprise-1.8.6-20090201/bin/ruby" "$@"

Comment (1)

  1. Tina Gabel wrote:

    Hi, I am developing a web site for persons with disabilities and am interested in the model you have used for Ravelry. I would love to speak with you regarding the platform structure you are using and wonder if you have a moment to speak with me offline about the tools you have used? I posted this question on Ravelry and thought I would try to reach you via this blog. Thank you in advance for your consideration of my request. Regards, Tina G.

    Wednesday, February 3, 2010 at 1:27 pm #