Skip to content

Instantly share code, notes, and snippets.

@zed9h
Created August 13, 2012 22:00
Show Gist options
  • Save zed9h/3344381 to your computer and use it in GitHub Desktop.
Save zed9h/3344381 to your computer and use it in GitHub Desktop.
helloworld microbenchmark of 3 webserver interfaces: perl/twiggy, ruby/rack, python/cyclone
Hello Word benchmark.
diff -Nr -U5 _/cyclone/hello.py ./cyclone/hello.py
--- _/cyclone/hello.py 1970-01-01 00:00:00.000000000 +0000
+++ ./cyclone/hello.py 2012-08-11 23:45:04.562124694 +0000
@@ -0,0 +1,11 @@
+import cyclone.web
+
+
+class MainHandler(cyclone.web.RequestHandler):
+ def get(self):
+ self.write("hello, world")
+
+
+Application = lambda: cyclone.web.Application([(r"/", MainHandler)])
+
+
diff -Nr -U5 _/rack/bench.rb ./rack/bench.rb
--- _/rack/bench.rb 1970-01-01 00:00:00.000000000 +0000
+++ ./rack/bench.rb 2012-08-13 19:54:20.834093157 +0000
@@ -0,0 +1,7 @@
+# encoding: UTF-8
+
+class Bench
+ def call(env)
+ [200, {"Content-Type" => "text/plain"}, ['Hello Word']]
+ end
+end
diff -Nr -U5 _/rack/config.ru ./rack/config.ru
--- _/rack/config.ru 1970-01-01 00:00:00.000000000 +0000
+++ ./rack/config.ru 2012-08-13 19:54:46.450091971 +0000
@@ -0,0 +1,5 @@
+# encoding: UTF-8
+
+require "bench"
+
+run Bench.new
diff -Nr -U5 _/twiggy/app.psgi ./twiggy/app.psgi
--- _/twiggy/app.psgi 1970-01-01 00:00:00.000000000 +0000
+++ ./twiggy/app.psgi 2012-08-13 21:21:20.202090690 +0000
@@ -0,0 +1,9 @@
+my $app = sub {
+ my $env = shift;
+ return [
+ '200',
+ [ 'Content-Type' => 'text/plain' ],
+ [ "Hello World" ], # or IO::Handle-like object
+ ];
+};
+
# # # # # #### #### ##### # # ##### #####
# # ## # # # # # # # # ## # # # # #
# # # # # # # # # # # # # # # # #####
# # # # # # # # # ##### # # # ### ##### # #
# # # ## # # # # # # # # ## ### # # # #
#### # # # #### #### # # # # ### # # #####
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ unicorn -I. -p 9292 &>/dev/null &
[1] 8088
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ siege -b -c 150 -t 5s http://localhost:9292
** SIEGE 2.70
** Preparing 150 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 2145 hits
Availability: 100.00 %
Elapsed time: 4.04 secs
Data transferred: 0.02 MB
Response time: 0.21 secs
Transaction rate: 530.94 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 110.15
Successful transactions: 2145
Failed transactions: 0
Longest transaction: 2.74
Shortest transaction: 0.00
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ httperf --uri / --port 9292 --hog --server localhost --num-conn 6000 --ra 2000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=9292 --uri=/ --rate=2000 --send-buffer=4096 --recv-buffer=16384 --num-conns=6000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 142
Total: connections 2044 requests 2044 replies 1239 test-duration 10.254 s
Connection rate: 199.3 conn/s (5.0 ms/conn, <=1022 concurrent connections)
Connection time [ms]: min 3.8 avg 982.9 max 4612.8 median 214.5 stddev 1446.2
Connection time [ms]: connect 1152.0
Connection length [replies/conn]: 1.000
Request rate: 199.3 req/s (5.0 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 14.3 avg 123.5 max 232.8 stddev 154.5 (2 samples)
Reply time [ms]: response 652.6 transfer 0.1
Reply size [B]: header 145.0 content 10.0 footer 2.0 (total 157.0)
Reply status: 1xx=0 2xx=1239 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.12 system 9.06 (user 1.2% system 88.3% total 89.5%)
Net I/O: 30.4 KB/s (0.2*10^6 bps)
Errors: total 4761 client-timo 804 socket-timo 0 connrefused 0 connreset 1
Errors: fd-unavail 3956 addrunavail 0 ftab-full 0 other 0
##### # # # # # ##### #####
# # # # ## # # # # #
# ###### # # # # # # #####
# # # # # # # ### ##### # #
# # # # # ## ### # # # #
# # # # # # ### # # #####
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ rackup -s thin -I. &> /dev/null &
[1] 8256
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ siege -b -c 150 -t 5s http://localhost:9292
** SIEGE 2.70
** Preparing 150 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 5329 hits
Availability: 100.00 %
Elapsed time: 4.78 secs
Data transferred: 0.05 MB
Response time: 0.11 secs
Transaction rate: 1114.85 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 127.70
Successful transactions: 5329
Failed transactions: 0
Longest transaction: 4.59
Shortest transaction: 0.00
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ httperf --uri / --port 9292 --hog --server localhost --num-conn 6000 --ra 2000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=9292 --uri=/ --rate=2000 --send-buffer=4096 --recv-buffer=16384 --num-conns=6000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 128
Total: connections 3202 requests 3188 replies 3186 test-duration 8.427 s
Connection rate: 380.0 conn/s (2.6 ms/conn, <=1022 concurrent connections)
Connection time [ms]: min 14.8 avg 1083.6 max 5823.7 median 192.5 stddev 1325.7
Connection time [ms]: connect 805.6
Connection length [replies/conn]: 1.000
Request rate: 378.3 req/s (2.6 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 622.0 avg 622.0 max 622.0 stddev 0.0 (1 samples)
Reply time [ms]: response 279.3 transfer 0.0
Reply size [B]: header 129.0 content 10.0 footer 2.0 (total 141.0)
Reply status: 1xx=0 2xx=3186 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.70 system 5.58 (user 8.3% system 66.2% total 74.5%)
Net I/O: 74.2 KB/s (0.6*10^6 bps)
Errors: total 2814 client-timo 16 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 2798 addrunavail 0 ftab-full 0 other 0
##### ## #### # # ##### #####
# # # # # # # # # # # #
# # # # # #### # # #####
##### ###### # # # ### ##### # #
# # # # # # # # ### # # # #
# # # # #### # # ### # # #####
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ rackup -I. &> /dev/null &
[1] 8415
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/rack$ siege -b -c 150 -t 5s http://localhost:9292
** SIEGE 2.70
** Preparing 150 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 5378 hits
Availability: 100.00 %
Elapsed time: 4.71 secs
Data transferred: 0.05 MB
Response time: 0.12 secs
Transaction rate: 1141.83 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 131.51
Successful transactions: 5378
Failed transactions: 0
Longest transaction: 3.12
Shortest transaction: 0.00
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/rack$ httperf --uri / --port 9292 --hog --server localhost --num-conn 6000 --ra 2000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=9292 --uri=/ --rate=2000 --send-buffer=4096 --recv-buffer=16384 --num-conns=6000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 72
Total: connections 3133 requests 3090 replies 3084 test-duration 6.620 s
Connection rate: 473.3 conn/s (2.1 ms/conn, <=1022 concurrent connections)
Connection time [ms]: min 14.8 avg 1057.6 max 5616.9 median 201.5 stddev 1254.1
Connection time [ms]: connect 813.0
Connection length [replies/conn]: 1.000
Request rate: 466.8 req/s (2.1 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 613.8 avg 613.8 max 613.8 stddev 0.0 (1 samples)
Reply time [ms]: response 245.0 transfer 0.0
Reply size [B]: header 129.0 content 10.0 footer 2.0 (total 141.0)
Reply status: 1xx=0 2xx=3084 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.28 system 4.19 (user 4.3% system 63.3% total 67.6%)
Net I/O: 91.5 KB/s (0.7*10^6 bps)
Errors: total 2916 client-timo 49 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 2867 addrunavail 0 ftab-full 0 other 0
##### # # # #### #### # # ##### #
# # # # # # # # # # # # #
# # # # # # # # # #
# # ## # # # ### # ### # ### ##### #
# ## ## # # # # # # ### # #
# # # # #### #### # ### # ######
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/twiggy$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/twiggy$ twiggy --listen :9292 &> /dev/null &
[1] 8575
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/twiggy$ siege -b -c 150 -t 5s http://localhost:9292
** SIEGE 2.70
** Preparing 150 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 9584 hits
Availability: 100.00 %
Elapsed time: 5.03 secs
Data transferred: 0.10 MB
Response time: 0.07 secs
Transaction rate: 1905.37 trans/sec
Throughput: 0.02 MB/sec
Concurrency: 133.94
Successful transactions: 9584
Failed transactions: 0
Longest transaction: 4.59
Shortest transaction: 0.00
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/cyclone$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/twiggy$ httperf --uri / --port 9292 --hog --server localhost --num-conn 6000 --ra 2000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=9292 --uri=/ --rate=2000 --send-buffer=4096 --recv-buffer=16384 --num-conns=6000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 66
Total: connections 6000 requests 6000 replies 6000 test-duration 3.003 s
Connection rate: 1998.2 conn/s (0.5 ms/conn, <=145 concurrent connections)
Connection time [ms]: min 0.5 avg 11.0 max 276.6 median 8.5 stddev 14.4
Connection time [ms]: connect 0.6
Connection length [replies/conn]: 1.000
Request rate: 1998.2 req/s (0.5 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 0.0 avg 0.0 max 0.0 stddev 0.0 (0 samples)
Reply time [ms]: response 9.9 transfer 0.5
Reply size [B]: header 45.0 content 11.0 footer 0.0 (total 56.0)
Reply status: 1xx=0 2xx=6000 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.26 system 1.24 (user 8.7% system 41.4% total 50.1%)
Net I/O: 230.3 KB/s (1.9*10^6 bps)
Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
#### # # #### # #### # # ###### ##### # #
# # # # # # # # # ## # # # # # #
# # # # # # # # # ##### # # #
# # # # # # # # # # ### ##### #
# # # # # # # # # ## # ### # #
#### # #### ###### #### # # ###### ### # #
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/cyclone$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/cyclone$ twistd -n cyclone -r hello.Application &>/dev/null &
[2] 8909
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/cyclone$ siege -b -c 150 -t 5s http://localhost:8888
** SIEGE 2.70
** Preparing 150 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 3723 hits
Availability: 100.00 %
Elapsed time: 4.04 secs
Data transferred: 0.04 MB
Response time: 0.15 secs
Transaction rate: 921.53 trans/sec
Throughput: 0.01 MB/sec
Concurrency: 135.02
Successful transactions: 3723
Failed transactions: 0
Longest transaction: 3.13
Shortest transaction: 0.02
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/cyclone$ netstat -n | grep TIME_WAIT -c
0
ubuntu@domU-12-31-39-02-1C-2A:~/comment/benchmark/helloworld/cyclone$ httperf --uri / --port 9292 --hog --server localhost --num-conn 6000 --ra 2000 --timeout 5
httperf --hog --timeout=5 --client=0/1 --server=localhost --port=9292 --uri=/ --rate=2000 --send-buffer=4096 --recv-buffer=16384 --num-conns=6000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 134
Total: connections 3474 requests 3458 replies 3458 test-duration 5.521 s
Connection rate: 629.3 conn/s (1.6 ms/conn, <=1022 concurrent connections)
Connection time [ms]: min 1.9 avg 929.7 max 4027.7 median 1032.5 stddev 926.2
Connection time [ms]: connect 746.1
Connection length [replies/conn]: 1.000
Request rate: 626.4 req/s (1.6 ms/req)
Request size [B]: 62.0
Reply rate [replies/s]: min 687.4 avg 687.4 max 687.4 stddev 0.0 (1 samples)
Reply time [ms]: response 183.6 transfer 0.0
Reply size [B]: header 155.0 content 12.0 footer 0.0 (total 167.0)
Reply status: 1xx=0 2xx=3458 3xx=0 4xx=0 5xx=0
CPU time [s]: user 0.21 system 3.25 (user 3.8% system 58.9% total 62.7%)
Net I/O: 140.1 KB/s (1.1*10^6 bps)
Errors: total 2542 client-timo 16 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 2526 addrunavail 0 ftab-full 0 other 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment