Created
March 9, 2016 22:24
-
-
Save lifuzu/aedc17a6037f004bd405 to your computer and use it in GitHub Desktop.
gevent python script to setup a hello world web server disabled log (http://lifuzu.com/blog/2014/01/05/performance-analysis-of-gevent-eventlet-and-nodejs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat geve.py | |
import gevent | |
from gevent import wsgi,pool | |
#the application to handle the response | |
def app(environ,start_response): | |
start_response("200 OK",[("Content-Type","text/plain")]) | |
return "Hello World\n" | |
if __name__=="__main__": | |
print "The sweet thing is running on http://localhost:8912/" | |
pool=gevent.pool.Pool() #A pool of greenlets.Each greenlets runs the above defined function app for a client request | |
server=wsgi.WSGIServer(("localhost",8912),app,spawn=pool,log=None) #the server is created and runs multiple greenlets concurrently | |
server.serve_forever() #the server is made to run in loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ ab -n 1000 -c 100 http://127.0.0.1:8912/
This is ApacheBench, Version 2.3 <$Revision: 1663405 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8912
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 0.535 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 133000 bytes
HTML transferred: 12000 bytes
Requests per second: 1868.30 #/sec
Time per request: 53.524 ms
Time per request: 0.535 [ms](mean, across all concurrent requests)
Transfer rate: 242.66 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.8 0 4
Processing: 5 51 9.7 51 66
Waiting: 4 50 9.7 51 66
Total: 9 51 9.0 51 66
Percentage of the requests served within a certain time (ms)
50% 51
66% 52
75% 53
80% 54
90% 61
95% 64
98% 65
99% 66
100% 66 (longest request)