Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created April 1, 2011 01:54
Show Gist options
  • Save guilleiguaran/897613 to your computer and use it in GitHub Desktop.
Save guilleiguaran/897613 to your computer and use it in GitHub Desktop.
Node.js vs EventMachine
require 'eventmachine'
require 'evma_httpserver'
class MyHttpServer < EM::Connection
include EM::HttpServer
def post_init
super
no_environment_strings
end
def process_http_request
response = EM::DelegatedHttpResponse.new(self)
response.status = 200
response.content_type 'text/plain'
response.content = 'Hello World\n'
response.send_response
end
end
EM.run{
EM.start_server '0.0.0.0', 8080, MyHttpServer
}
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
Apache 2.2.17 (for reference)
--------------
Server Software: Apache/2.2.17
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 1.015 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2990299 bytes
HTML transferred: 130013 bytes
Requests per second: 9856.85 [#/sec] (mean)
Time per request: 10.145 [ms] (mean)
Time per request: 0.101 [ms] (mean, across all concurrent requests)
Transfer rate: 2878.41 [Kbytes/sec] received
Node.js 0.4.2
--------------
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8124
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 1.334 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 760000 bytes
HTML transferred: 120000 bytes
Requests per second: 7496.66 [#/sec] (mean)
Time per request: 13.339 [ms] (mean)
Time per request: 0.133 [ms] (mean, across all concurrent requests)
Transfer rate: 556.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 4
Processing: 1 13 6.2 13 31
Waiting: 1 13 6.2 13 30
Total: 2 13 6.2 13 31
Percentage of the requests served within a certain time (ms)
50% 13
66% 16
75% 18
80% 19
90% 22
95% 23
98% 25
99% 27
100% 31 (longest request)
EventMachine 0.12.10 (MRI 1.8.7)
--------------------------------
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 1.063 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 790711 bytes
HTML transferred: 130117 bytes
Requests per second: 9407.26 [#/sec] (mean)
Time per request: 10.630 [ms] (mean)
Time per request: 0.106 [ms] (mean, across all concurrent requests)
Transfer rate: 726.41 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 10
Processing: 2 10 4.1 9 25
Waiting: 1 9 4.0 8 25
Total: 5 11 4.0 9 26
Percentage of the requests served within a certain time (ms)
50% 9
66% 10
75% 10
80% 10
90% 19
95% 22
98% 24
99% 25
100% 26 (longest request)
EventMachine 0.12.10 (YARV 1.9.2)
---------------------------------
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 0.868 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 790316 bytes
HTML transferred: 130052 bytes
Requests per second: 11522.97 [#/sec] (mean)
Time per request: 8.678 [ms] (mean)
Time per request: 0.087 [ms] (mean, across all concurrent requests)
Transfer rate: 889.33 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 4
Processing: 1 8 3.3 8 18
Waiting: 1 8 3.2 7 18
Total: 4 9 3.2 8 19
Percentage of the requests served within a certain time (ms)
50% 8
66% 8
75% 8
80% 9
90% 15
95% 17
98% 18
99% 18
100% 19 (longest request)
@sleeptillseven
Copy link

Awesome. Do you run node in production mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment