Skip to content

Instantly share code, notes, and snippets.

@sugar84
Created May 2, 2011 21:03
Show Gist options
  • Save sugar84/952361 to your computer and use it in GitHub Desktop.
Save sugar84/952361 to your computer and use it in GitHub Desktop.
twiggy vs node.js vs HTTP::Server::Simple::PSGI
----------------------------------------------------------
== Twiggy ==
app.psgi:
my $app = sub {
return [ 200, ['Content-Type' => 'text/plain'], [ "Hello world\n"] ];
};
[sugar@host dir]$ twiggy --listen 127.0.0.1:8080 app.psgi
[sugar@host dir]$ /usr/sbin/ab -n4000 -c100 -k 127.0.0.1:8080/
Benchmarking 127.0.0.1 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Finished 4000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 0.562 seconds
Complete requests: 4000
Failed requests: 0
Broken pipe errors: 0
Keep-Alive requests: 0
Total transferred: 228000 bytes
HTML transferred: 48000 bytes
Requests per second: 7117.44 [#/sec] (mean)
Time per request: 14.05 [ms] (mean)
Time per request: 0.14 [ms] (mean, across all concurrent requests)
Transfer rate: 405.69 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 2.4 0 17
Processing: 1 13 6.4 13 59
Waiting: 0 13 6.3 13 59
Total: 1 13 7.5 13 64
Percentage of the requests served within a certain time (ms)
50% 13
66% 13
75% 13
80% 13
90% 14
95% 17
98% 29
99% 63
100% 64 (last request)
----------------------------------------------------------
== node.js ==
test_http.js:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
[sugar@host dir]$ ./node test_http.js
[sugar@host dir]$ /usr/sbin/ab -n4000 -c100 -k 127.0.0.1:1337/
Benchmarking 127.0.0.1 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Finished 4000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 1337
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 0.660 seconds
Complete requests: 4000
Failed requests: 0
Broken pipe errors: 0
Keep-Alive requests: 0
Total transferred: 304000 bytes
HTML transferred: 48000 bytes
Requests per second: 6060.61 [#/sec] (mean)
Time per request: 16.50 [ms] (mean)
Time per request: 0.17 [ms] (mean, across all concurrent requests)
Transfer rate: 460.61 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.5 0 11
Processing: 2 15 9.4 13 43
Waiting: 0 15 9.4 13 43
Total: 2 16 9.2 14 43
Percentage of the requests served within a certain time (ms)
50% 14
66% 18
75% 22
80% 25
90% 31
95% 34
98% 37
99% 39
100% 43 (last request)
----------------------------------------------------------
== HTTP::Server::Simple::PSGI ==
http_simple.pl:
#!/usr/bin/env perl
use common::sense;
use HTTP::Server::Simple::PSGI;
my $server = HTTP::Server::Simple::PSGI->new(3000);
$server->host("127.0.0.1");
$server->app( sub {
return [ 200, [ 'Content-Type', 'text/plain' ], [ "Hello World\n" ] ]
});
$server->run;
[sugar@host dir]$ perl http_simple.pl
[sugar@host dir]$ /usr/sbin/ab -n4000 -c100 -k 127.0.0.1:3000/
Benchmarking 127.0.0.1 (be patient)
Completed 400 requests
Completed 800 requests
Completed 1200 requests
Completed 1600 requests
Completed 2000 requests
Completed 2400 requests
Completed 2800 requests
Completed 3200 requests
Completed 3600 requests
Finished 4000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 3000
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 2.042 seconds
Complete requests: 4000
Failed requests: 0
Broken pipe errors: 0
Keep-Alive requests: 0
Total transferred: 228000 bytes
HTML transferred: 48000 bytes
Requests per second: 1958.86 [#/sec] (mean)
Time per request: 51.05 [ms] (mean)
Time per request: 0.51 [ms] (mean, across all concurrent requests)
Transfer rate: 111.66 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 3
Processing: 1 50 6.4 54 56
Waiting: 0 50 6.5 54 56
Total: 1 50 6.4 54 56
Percentage of the requests served within a certain time (ms)
50% 54
66% 54
75% 54
80% 54
90% 54
95% 55
98% 56
99% 56
100% 56 (last request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment