Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails vs. Sinatra process memory usage?

Can anyone comment on the improvement per process of moving to Sinatra?

I find that my web API uses around 100MB per Passenger Rails 3 process. I'm wondering what the improvement would be if I switched to Sinatra.

like image 264
Dogweather Avatar asked Dec 28 '22 22:12

Dogweather


1 Answers

Here's a random not-real-world benchmark to give you just a little idea:

               |   Real  | Private | Vir. Priv. |
---------------+---------+---------+------------|
[1]      Rails |  38.6MB |  35.9MB |   76.3MB   |
---------------+---------+---------+------------|
[2]    Sinatra |  18.7MB |  16.2MB |   51.7MB   |
---------------+---------+---------+------------|
[3]     + Haml |  19.6MB |  17.0MB |   53.7MB   |
---------------+---------+---------+------------|
[4]   + Sequel |  24.4MB |  21.7MB |   54.8MB   |
---------------+---------+---------+------------|
  1. Rails 3.0.7, create a shell project, start the server, make 1 request.
  2. Sinatra 1.2.3 with Thin 1.2.11, require 'sinatra'; get('/'){ "Hello" }, make 1 request.
  3. ...add Haml 3.0.25, get ('/'){ haml "%p Hello" }, make 1 request.
  4. ...add Sequel 3.22.0, DB = Sequel.sqlite, make 1 request.

All tested on OS X. This test shows that a) Sinatra is far more bare-bones than Rails, and b) you will need to compare apples to apples (on the OS of your choice ;) if you want any meaningful numbers. The same application with the same functionality.

My real-world apps running on Windows using Thin+Sequel+Haml+pg tend to run around 50-90MB per instance (depending on the app I run 2-4 instances behind a reverse proxy). YMMV.

like image 96
Phrogz Avatar answered Jan 11 '23 20:01

Phrogz