I was reading about heroku and found Unicorn over Thin can be better option.

Some admin points for heroku :
1) Heroku is just a simple unix platform; specifically, Ubuntu 10.04 LTS.(try this)
$ heroku run bash
Running `bash` attached to terminal… up, run.1
$ uname -a
Linux f780edbd-5880-44f1-b3f3-ce436852324f 2.6.32-343-ec2 #45+lp929941v1 SMP Tue Feb 21 14:07:44 UTC 2012 x86_64 GNU/Linux
$ cat /etc/issue
Ubuntu 10.04 LTS \n \l
$ cat /proc/cpuinfo
512MB of RAM, 1GB of swap. Total = 1.5GB RAM.
4 CPU cores (Intel Xeon X5550 @ 2.67GHz).
Isolated execution. Anything you store on your dyno will be isolated from all other dynos.
$ cat /proc/meminfo
$ top
300x250-hosting

2) Heroku Cedar uses Thin as server over Dyno.
to scale environment we should know some thing about heroku.
Process:
A basic Rails app will typically have two process types:
1. A Rack-compatible web process (such as Webrick, Mongrel, or Thin)
2. A worker process using a queueing library (such as Delayed Job or Resque).

A process type is the prototype from which one or more processes are instantiated. This is similar to the way a class is the prototype from which one or more objects are instantiated in object-oriented programming.

How many requests can a dyno (Thin) serve?
This depends greatly on the language and framework used. A single-threaded, non-concurrent framework like Rails can process one request at a time. For a “typical” app, this translates to about 10 requests per second if each request has an average response time of 100ms.

How unicorn works?
The Unicorn master process receives all incoming HTTP requests and acts as a load balancer for the 4 sub processes (workers) and passes on the request to the first available sub process.
ref : http://unicorn.bogomips.org/

Here what we can try?
Since Unicorn’s one worker is roughly equivalent to a Thin instance.
Heroku only put a single Thin instance on a dyno, meaning that if we are using 3 worker of Unicorn so we have 3 thin process.
If app is doing any network IO,so unicorn + multiple worker processes to give even better results over thin.
With Unicorn we can gain 3 to 4 times more throughput.

how to configure unicorn follow this link
http://kuon.goyman.com/2012/heroku_unicorn/

Since on heroku you can use MRI ruby 1.9.3 so given link is benchmarking over MRI ruby 1.9.3 and servers
http://jgwmaxwell.com/mri-performance-shootout/
it shows that Unicorn performs better than Thin.

References:
http://neilmiddleton.com/getting-more-from-your-heroku-dynos/
http://michaelvanrooijen.com/articles/2011/06/01-more-concurrency-on-a-sing…
http://bugsplat.info/2011-11-27-concurrency-on-heroku-cedar.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s