This is just an exercise to measure the performance between Sinatra-like libraries in:
-
Elixir v0.4.dev (running on top of the Erlang VM R14B03) with Dynamo;
-
Ruby 1.9.2 with [Sinatra Synchrony] v0.0.3 (https://github.com/kyledrake/sinatra-synchrony) + Thin;
-
node.js 0.4.7 with [express] v2.3.10(https://github.com/visionmedia/express)
The basic example uses only a single route at /hello_world
and return Hello world
. These benchmarks are extremely simple and should not be used as a decision factor for any of the tools presented (unless you are building hello world apps ;). I am just using them as performance guideline when working on Dynamo.
This benchmark also measures what happens if you add 10, 100 and 1000 /hello_world/#{i}
routes and try to match the last /hello_world/1000
route.
We also check the behavior of the app when it has to serve a file with 100kb of size.
Just trolling bro.
Results were obtained by running the examples below in a Macbook Pro 2011 2.3GHz dual-core Intel Core i5. No customization was done to the underlying VM/Engine/Webserver besides passing the "production" flag to all libraries, i.e. I am measuring the out-of-the-box experience. This means Elixir is running on both cores, while the other solutions aren't. This is one of the several benefits of using the Erlang VM.
req/s average for 8000 requests, concurrency 40 (ab -n 8000 -c 40
) (more is better):
Routes | Dynamo/Elixir | SinatraS/Ruby 1.9.2 | Express/node.js 0.4.7
1 | 9135.83 | 3833.54 | 4730.74
10 + 1 | 9105.35 | 3561.69 | 4635.8
100 + 1 | 9103.91 | 2472.51 | 4171.94
1000 + 1 | 9043.72 | 598.47 | 1904.71
100kb file | 6087.99 | 2088.66 | 1734.17
Thanks to the Erlang VM, Dynamo performs very well in the basic hello world case. Indeed, Dynamo is in very early stage and the throughput will reduce by a couple dozens req/s
as we add more basic features. Regardless, very good results.
It is also important to notice that increasing the number of routes increases the CPU usage which will block on single process, non threaded solutions like Node.js, affecting throughput. Also the performance of the algorithm used in the routes matching matters in the results above.
In the future, I plan to draw graphs on how those examples behave when increasing the concurrency. In early experiments, both Sinatra and Express throughput starts to decrease early on when increasing the concurrency. I also want to run benchmarks against those servers deployed on Heroku, but not sure if i need their permission first or anything. :)
Promising results. Are You planning to prepare whole non-blocking stdlib for Elixir?
What is Dynamo? The README isn't descriptive.
Numbers are OK for regular apps but if You can lift them even more it could be agile competitor for libevent or for example LMAX Disruptor on APIs and services field.