RubyWorks: Production Stack for Rails

Well, we all know how hard, or at least cumbersome, it can be to set up a production environment to deploy your applications. Besides all the hardware stuff like storages, links, routers you are still left with a huge amount of software configuration to handle. This often includes configuring things like clusters, load balancing and services monitoring - Including notification of interested parts in case of any failure. Pieces of software you have to tie up and make them work together.

But hey, ruby lovers, you may have a better way to get this going! Released by ThoughtWorks, RubyWorks is, as quoted from their website, a production application stack for Ruby On Rails applications. I decided to give it a try and I really enjoyed it.

First of all I didn’t want to mess with my actual configuration so I installed a new vm with Virtual Box. It has Ubuntu 7.10 on it, with 256MB of memory.

After installing RubyWorks - instructions on their website -, you get a new skeleton rails app up and running, being served by 4 mongrels that defaults to production environment! Impressed? There is more. A HAProxy is also set up in front of your mongrel servers acting as a load balancer.

Well, you probably want to monitor all that stuff huh? A monit web interface is waiting for your call on port 2812! It monitors all your mongrel servers - four by default - and your HAProxy, allowing you to measure CPU and Memory usage, among other things.

The coolest thing here is that all these softwares you would have to setup by hand are already working together, ready for production! Well, is it?

Going a little deeper, I deployed a database backed application to test this stack’s performance.

I used Siege to stress the app and I am very happy with the results! I compared it with a single mongrel running on production env and no proxy at all.

It is worth mentioning that having 4 mongrels running took my vm to 77% of memory usage, while a single mongrel took it to 38%.



The test was made simulating 200 concurrent users on a simple listing page, lasting 1 minute. And the results are:
[code]
RubyWorks - 77% memory usage
————–
Transactions: 1511 hits
Availability: 100.00 %
Elapsed time: 60.45 secs
Data transferred: 3.32 MB
Response time: 4.65 secs
Transaction rate: 25.00 trans/sec
Throughput: 0.05 MB/sec
Concurrency: 116.33
Successful transactions: 1513
Failed transactions: 0
Longest transaction: 15.85
Shortest transaction: 0.01
[/code]
[code]
Mongrel - production environment - 38% memory usage
———–
Transactions: 1460 hits
Availability: 100.00 %
Elapsed time: 67.96 secs
Data transferred: 3.20 MB
Response time: 7.33 secs
Transaction rate: 21.48 trans/sec
Throughput: 0.05 MB/sec
Concurrency: 157.57
Successful transactions: 1460
Failed transactions: 0
Longest transaction: 17.78
Shortest transaction: 0.01
[/code]

Wow!

That is a big difference! In less time, with less resources - remember the 77% against 38%? - the out-of-the-box RubyWorks setup was able to handle more requests at a time, and with a lower response time! Even in a machine with very low resources (256MB)!

This result actually was expected but it was awesome to show that this stack is powerful without touching it and is a very good starting point to tailor your environment, without having to worry about configuring all this stuff. Just focus on fine tuning it, if you need!

Oh, and by the way, I didn’t even put an apache in front of that, which is highly recommended for a prod environment!

See you on the next post!

UPDATE 12/1 - 4:25 PM : I fogot to mention that besides all this configuration, it installs ruby and its dependencies as well.

Comments