Skip to content

Instantly share code, notes, and snippets.

@e000
Created January 31, 2011 22:35
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 e000/804977 to your computer and use it in GitHub Desktop.
Save e000/804977 to your computer and use it in GitHub Desktop.
basehttpserver vs gevent
e@e-desktop:~/proxybot/bench$ ab -c 50 -n 5000 http://localhost:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests
Server Software: BaseHTTP/0.3
Server Hostname: localhost
Server Port: 8000
Document Path: /
Document Length: 12 bytes
Concurrency Level: 50
Time taken for tests: 2.265 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 640000 bytes
HTML transferred: 60000 bytes
Requests per second: 2207.31 [#/sec] (mean)
Time per request: 22.652 [ms] (mean)
Time per request: 0.453 [ms] (mean, across all concurrent requests)
Transfer rate: 275.91 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 2
Processing: 0 3 45.2 2 2263
Waiting: 0 3 45.2 2 2263
Total: 1 3 45.2 2 2265
Percentage of the requests served within a certain time (ms)
50% 2
66% 2
75% 2
80% 2
90% 3
95% 3
98% 4
99% 4
100% 2265 (longest request)
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class Handler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_headers()
self.wfile.write('Hello World!')
if __name__ == '__main__':
try:
server = HTTPServer(('', 8000), Handler)
print 'Listening on 0.0.0.0:8000'
server.serve_forever()
except KeyboardInterrupt:
print '^C, halting'
server.socket.close()
e@e-desktop:~/proxybot/bench$ ab -c 50 -n 5000 http://localhost:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests
Server Software: gevent/0.13
Server Hostname: localhost
Server Port: 8000
Document Path: /
Document Length: 12 bytes
Concurrency Level: 50
Time taken for tests: 0.917 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 635000 bytes
HTML transferred: 60000 bytes
Requests per second: 5449.80 [#/sec] (mean)
Time per request: 9.175 [ms] (mean)
Time per request: 0.183 [ms] (mean, across all concurrent requests)
Transfer rate: 675.90 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 5
Processing: 2 9 1.3 9 16
Waiting: 2 9 1.2 9 15
Total: 4 9 1.2 9 16
Percentage of the requests served within a certain time (ms)
50% 9
66% 9
75% 9
80% 9
90% 10
95% 11
98% 13
99% 13
100% 16 (longest request)
from gevent import wsgi
def hello_world(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ["Hello World!"]
print "Listening on 0.0.0.0:8000"
wsgi.WSGIServer(('', 8000), hello_world).serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment