We're hiring!

We're actively seeking designers and developers for all three of our locations.

Slow Ruby Install on Joyent

We are using Joyent to host a Ruby on Rails application. We noticed that our application seemed be running slower on our Joyent slice than our personal laptops. Out of curiosity we decided to run a simple benchmark test using irb on both our Joyent slice and our development machine. The following is the script that we ran.


require 'benchmark'; puts Benchmark.measure { 5000000.times {  1 + 1 } }

We were shocked to see a huge difference between our development machines, and our Joyent slice that was running ruby version ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-solaris2].

Development machine time:

1
2
>> require 'benchmark'; puts Benchmark.measure { 5000000.times {  1 + 1 } }
  1.070000   0.000000   1.070000 (  1.079934)

Joyent Slice time:

1
2
irb(main):001:0> require 'benchmark'; puts Benchmark.measure { 5000000.times {  1 + 1 } }
  2.070000   2.650000   4.720000 (  4.723583)

In order to correct the problem on our Joyent slice we compiled ruby 1.8.7 from source. After making this update we saw a huge improvement in the processing time.

Joyent Slice time after ruby update:

1
2
irb(main):001:0> require 'benchmark'; puts Benchmark.measure { 5000000.times {  1 + 1 } }
  0.890000   0.000000   0.890000 (  0.891699)

An incredible improvement! Really makes us wonder what kind of ruby install Joyent does out of the box.

The following walk through describes how we went about updating our Joyent slice. We found that this approach was much easier than trying to remove the old install of ruby.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Download, compile and install ruby 1.8.7 in /opt/ruby187
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz
tar zxf ruby-1.8.7.tar.gz
cd ruby-1.8.7
./configure --with-openssl-dir=/opt/local --with-readline-dir=/opt/local --with-iconv-dir=/opt/local --prefix=/opt/ruby187
make
sudo make install

# Download and install rubygems
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar zxf rubygems-1.3.1.tgz
cd rubygems-1.3.1
export GEM_HOME=/opt/ruby187/lib/gems
sudo /opt/ruby187/bin/ruby setup.rb

# Install gems needed to run the application
sudo /opt/ruby187/bin/gem install rake mongrel_cluster mysql

Edit .profile and put /opt/ruby187/bin at the beginning of the path.

This article on the Joyent wiki provided most of the steps we needed to take.

Michael Marsiglia (53 Posts)

Michael is a Vice President at Atomic Object. He has 12 years experience in software development, as a developer and as a part Atomic’s upfront team, helping clients match their business needs with custom software solutions. ‬

Mike is passionate about guiding clients through the development of effective products. He enjoys the challenge of figuring out how to build successful software tools, employing a minimum set of essential features.‬

This entry was posted in Ruby and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.

One Comment

  1. Posted February 23, 2009 at 3:53 pm

    You should add the –disable-pthread to your ./configure options for another 20-80% performance boost.