Skip to content

Instantly share code, notes, and snippets.

@bogdanconstantinescu
Created September 13, 2012 15:48
Show Gist options
  • Select an option

  • Save bogdanconstantinescu/3715241 to your computer and use it in GitHub Desktop.

Select an option

Save bogdanconstantinescu/3715241 to your computer and use it in GitHub Desktop.

Revisions

  1. bogdanconstantinescu revised this gist Sep 13, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    - ruby 1.9.3p194
    - async_sinatra (1.0.0)
    - thin (1.2.11)

    <pre>
    thin start

  2. bogdanconstantinescu revised this gist Sep 13, 2012. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,12 +3,13 @@
    - ruby 1.9.3p194
    - async_sinatra (1.0.0)
    - thin (1.2.11)

    thin start
    <pre>
    thin start

    ab -n 10000 -c 100 http://127.0.0.1:3000/
    </pre>


    <pre>
    Server Software: thin
    Server Hostname: 127.0.0.1
    Server Port: 3000
    @@ -45,17 +46,20 @@
    98% 78
    99% 94
    100% 119 (longest request)
    </pre>

    # Node.js

    - node v0.8.8
    - express 3.0.0rc4

    <pre>
    node app.js

    ab -n 10000 -c 100 http://localhost:3001/
    </pre>


    <pre>
    Server Software:
    Server Hostname: 127.0.0.1
    Server Port: 3001
    @@ -92,7 +96,7 @@
    98% 299
    99% 312
    100% 405 (longest request)

    </pre>

    # Conclusion
    Ruby still has it (besides being a beautiful language).
  3. bogdanconstantinescu revised this gist Sep 13, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    - async_sinatra (1.0.0)
    - thin (1.2.11)

    thin start
    thin start

    ab -n 10000 -c 100 http://127.0.0.1:3000/

  4. @invalid-email-address Anonymous created this gist Sep 13, 2012.
    7 changes: 7 additions & 0 deletions Gemfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    source 'https://rubygems.org'

    gem 'thin'
    gem 'bundler'

    gem 'async_sinatra'
    gem 'thin'
    98 changes: 98 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    # Async Sinatra

    - ruby 1.9.3p194
    - async_sinatra (1.0.0)
    - thin (1.2.11)

    thin start

    ab -n 10000 -c 100 http://127.0.0.1:3000/


    Server Software: thin
    Server Hostname: 127.0.0.1
    Server Port: 3000

    Document Path: /
    Document Length: 11 bytes

    Concurrency Level: 100
    Time taken for tests: 5.439 seconds
    Complete requests: 10000
    Failed requests: 0
    Write errors: 0
    Total transferred: 1530000 bytes
    HTML transferred: 110000 bytes
    Requests per second: 1838.52 [#/sec] (mean)
    Time per request: 54.391 [ms] (mean)
    Time per request: 0.544 [ms] (mean, across all concurrent requests)
    Transfer rate: 274.70 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 1 2.0 1 37
    Processing: 15 53 10.8 52 119
    Waiting: 12 49 10.1 48 96
    Total: 25 54 10.6 53 119

    Percentage of the requests served within a certain time (ms)
    50% 53
    66% 57
    75% 61
    80% 62
    90% 65
    95% 72
    98% 78
    99% 94
    100% 119 (longest request)

    # Node.js

    - node v0.8.8
    - express 3.0.0rc4

    node app.js

    ab -n 10000 -c 100 http://localhost:3001/


    Server Software:
    Server Hostname: 127.0.0.1
    Server Port: 3001

    Document Path: /
    Document Length: 170 bytes

    Concurrency Level: 100
    Time taken for tests: 14.909 seconds
    Complete requests: 10000
    Failed requests: 0
    Write errors: 0
    Total transferred: 3290000 bytes
    HTML transferred: 1700000 bytes
    Requests per second: 670.71 [#/sec] (mean)
    Time per request: 149.095 [ms] (mean)
    Time per request: 1.491 [ms] (mean, across all concurrent requests)
    Transfer rate: 215.49 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 0 0.8 0 21
    Processing: 2 148 84.1 146 405
    Waiting: 2 148 84.1 146 405
    Total: 2 148 84.1 146 405

    Percentage of the requests served within a certain time (ms)
    50% 146
    66% 192
    75% 218
    80% 233
    90% 263
    95% 281
    98% 299
    99% 312
    100% 405 (longest request)


    # Conclusion
    Ruby still has it (besides being a beautiful language).
    36 changes: 36 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    //Nothe this is a default installation on Express.js

    /**
    * Module dependencies.
    */

    var express = require('express')
    , routes = require('./routes')
    , user = require('./routes/user')
    , http = require('http')
    , path = require('path');

    var app = express();

    app.configure(function(){
    app.set('port', process.env.PORT || 3001);
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(path.join(__dirname, 'public')));
    });

    app.configure('development', function(){
    app.use(express.errorHandler());
    });

    app.get('/', routes.index);
    app.get('/users', user.list);

    http.createServer(app).listen(app.get('port'), function(){
    console.log("Express server listening on port " + app.get('port'));
    });
    14 changes: 14 additions & 0 deletions app.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # default example for async_sinatra gem
    require 'sinatra/async'

    class App < Sinatra::Base
    register Sinatra::Async

    aget '/' do
    body "hello async"
    end

    aget '/delay/:n' do |n|
    EM.add_timer(n.to_i) { body { "delayed for #{n} seconds" } }
    end
    end
    3 changes: 3 additions & 0 deletions config.ru
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    require './app'

    run App