What Have We Been Doing?

Posted by Ron Valente Mon, 14 Apr 2008 16:29:00 GMT

Introduction

Lately I have been working hard testing many deployment options for rails applications. The results are quite interesting. I will be going into detail analysis of each setup that we testing including hardware I used, how I setup each test, the benchmarks (obviously) and lastly the winners for each category. As we know DHH doesnt recommend Rails apps to be hosted on shared hosting solutions. That being said Slicehost has done wonderfully and we recommend them highly.

Our Situation

We have been looking for a way to optimize our rails app hosting solution. Currently we use Litespeed 3.3.9 and the Ruby LSAPI. This decreases the memory requirements immensely compared to other solutions like thin.

Testing

Ruby Interpreter Tests

  • Ruby18/JRuby - Performance & Memory Requirements

WebServer Tests

  • Nginx with Mongrel
  • Nginx with Thin
  • Litespeed
  • Apache with Passenger
  • Glassfish/JRuby

More on all of this in my upcoming post. Any comments are requests for benchmarks are welcome and encouraged!

Regards, Ron

Enabling the ULE scheduler for FreeBSD 7 1

Posted by Ron Valente Tue, 04 Mar 2008 00:25:00 GMT

Most of the performance benefit in FreeBSD is gained by switching from the default 4BSD scheduler to the ULE scheduler. This scheduler was introduced to FreeBSD in version 5. Since its induction to FreeBSD it has seen many improvements. By the end of this guide you will be booted into FreeBSD 7 and using the ULE scheduler.

cd /usr/src/sys/amd64/conf
cp GENERIC CUSTOM
ee CUSTOM

There are two things to change in this file then we can move to compiling and installing the new and improved kernel.

ident        CUSTOM
options       SCHED_ULE

Thats it! once that is done running the following commands and reboot.

cd /usr/src
make kernel KERNCONF=CUSTOM

Ruby Performance Revisited 6

Posted by Ron Valente Thu, 21 Feb 2008 04:28:00 GMT

For this post I used a code snippet I found from a fellow programmer, Antonio Cangiano, that ran the tests again myself because I couldnt believe my eyes of the benchmarks run by that user.

Fibonacci Language Shootout:

Languages

  • Ruby 1.8.6
  • Ruby 1.9.0 (Development Release)
  • Python 2.5.1
  • Perl 5.8.8
  • Java 1.5.0
  • C++

Below are the languages and the times that each took to run the code. The code for each languages is below near the end of the post.

Ruby 1.8.6

real 0m44.965s

Python 2.5.1

real 0m28.283s

Ruby 1.9.0

real 0m11.352s

C++

real 0m0.765s

Java

real 0m0.638s

Perl

real 0m70.383s

I will be comparing this performance of Ruby and Python to a program written in C. Below is the code used in these examples. Feel free to comment. I am running further tests using statistical analysis to make the output exhibit less of a standard deviation.

Python

def fib(n):
   if n == 0 or n == 1:
      return n
   else:
      return fib(n-1) + fib(n-2)

for i in range(36):
    fib(i)

Ruby

def fib(n)
  if n == 0 || n == 1
    n
  else
    fib(n-1) + fib(n-2)
  end
end

36.times do |i|
  fib(i)
end

Below is the source code for the fib sequence written in C++. Paul Solt recommended that the tests be performed without and writing to STDOUT due to the variability and slow down caused by writing to STDOUT. Since this was done for the C++ code it was done for the rest of the examples above. For the record there was no increase in speed when the output was removed.

C++

#include <stdio.h>
#include <iostream>

int fib( int n ) { 
    if( n== 0 || n == 1 ) { 
        return n; 
    } else {
        return fib( n -1) + fib( n-2); 
    }
}

int main() { 
    for( int i = 0; i < 36; i++ ) {
        fib(i);
    }
    return 0; 
}

Java

public class fibtest {
    public static void main(String[] args) { 
        for(int i=0; i<36; i++) {
            fib(i);     
        }
    }
    public static int fib(int n) {
        if( n == 0 || n == 1 )
            return n; 
        } else {
            return fib(n-1) + fib(n-2);
        }
    }
}

Perl

sub fib { return $[0] if $[0] == 0 || $_[0] == 1; fib($[0]-1) + fib($[0]-2); }

for($i=0;$i<36;$i++) { fib($i); }

I would like to extend my thanks to the developers that submitted, or contributed to this post in anyway.

Ruby & Python Code

Paul Solt - C Developer

Java & Perl Code - Jason Koppe