Skip to content

Instantly share code, notes, and snippets.

@methane
Created May 8, 2014 22:52
Show Gist options
  • Save methane/162b0230190117064e8e to your computer and use it in GitHub Desktop.
Save methane/162b0230190117064e8e to your computer and use it in GitHub Desktop.
import gevent.monkey
gevent.monkey.patch_all()
import flask
from flask.ext.sqlalchemy import SQLAlchemy
app = flask.Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root@localhost/test'
db = SQLAlchemy(app)
@app.route('/')
def index():
db.session.execute('SELECT SLEEP(3)')
return "Hello"
if __name__ == '__main__':
app.run(debug=True)
$ gunicorn -R --debug --access-logfile - --error-logfile - -k gevent app:app
2014-05-09 07:49:58 [89902] [INFO] Starting gunicorn 18.0
2014-05-09 07:49:58 [89902] [INFO] Listening at: http://127.0.0.1:8000 (89902)
2014-05-09 07:49:58 [89902] [INFO] Using worker: gevent
2014-05-09 07:49:58 [89905] [INFO] Booting worker with pid: 89905
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:03] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:06] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:09] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
127.0.0.1 - - [09/May/2014:07:50:12] "GET / HTTP/1.1" 200 5 "-" "-"
^C
2014-05-09 07:50:29 [89905] [INFO] Worker exiting (pid: 89905)
2014-05-09 07:50:29 [89902] [INFO] Handling signal: int
2014-05-09 07:50:30 [89902] [INFO] Shutting down: Master
$ wrk -d 10 -c 10 --latency --timeout 5 http://127.0.0.1:8000/
Running 10s test @ http://127.0.0.1:8000/
2 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 3.01s 253.14us 3.01s 100.00%
Req/Sec 1.00 0.00 1.00 100.00%
Latency Distribution
50% 3.01s
75% 3.01s
90% 3.01s
99% 3.01s
30 requests in 10.01s, 4.89KB read
Requests/sec: 3.00
Transfer/sec: 500.73B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment