Skip to content

Instantly share code, notes, and snippets.

@systembell
Forked from Evangenieur/Readme.md
Created August 25, 2011 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save systembell/1169940 to your computer and use it in GitHub Desktop.
Save systembell/1169940 to your computer and use it in GitHub Desktop.

Sinatra

ruby 1.9.2 + async_sinatra + thin thin start

ab -n 10000 -c 100 http://localhost:3000/
-> 49ms / request

Node

node server.js

ab -n 10000 -c 100 http://localhost:3000/
-> 20ms / request

EventMachine HttpServer

ruby em_http_serv.rb

ab -n 10000 -c 100 http://localhost:3000/
-> 12ms / request

Goliath

ruby hello.rb -e prod -p 3000

ab -n 10000 -c 100 http://localhost:3000/
-> 50ms / request
#!/usr/bin/env
require 'sinatra/async'
class AsyncTest < Sinatra::Base
register Sinatra::Async
aget '/' do
body "hello async"
end
end
run AsyncTest.new
require 'rubygems'
require 'eventmachine'
require 'evma_httpserver'
class Handler < EventMachine::Connection
include EventMachine::HttpServer
def process_http_request
resp = EventMachine::DelegatedHttpResponse.new( self )
resp.status = 200
resp.content = "Hello World\n"
resp.send_response
end
end
EventMachine::run {
EventMachine.epoll
EventMachine::start_server("0.0.0.0", 3000, Handler)
puts "Listening..."
}
require 'goliath'
class Hello < Goliath::API
def response(env)
[200, {}, "Hello World!"]
end
end
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(3000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment