使用工具:siege
代码结构:
hello.py
templates
|--hello.html
hello.py代码:
from flask import Flask, render_templateapp = Flask(__name__) @app.route(‘/‘)@app.route(‘/<name>‘)def index(name=None): return render_template(‘hello.html‘,name=name) if __name__ == ‘__main__‘: app.run(host=‘0.0.0.0‘,port=13579, debug=False)
hello.html代码:
from Flask</title>{% if name %}<h1>Hello {{ name }}!</h1>{% else %}<h1>Hello World!</h1>{% endif %}
flask
命令:siege -c 1000 -r 100 -b http://127.0.0.1:13579/3344
结果:
Transactions: 29511 hitsAvailability: 95.08 %Elapsed time: 254.69 secsData transferred: 1.15 MBResponse time: 1.16 secsTransaction rate: 115.87 trans/secThroughput: 0.00 MB/secConcurrency: 134.19Successful transactions: 29511Failed transactions: 1527Longest transaction: 88.56Shortest transaction: 0.00
gunicorn
命令:gunicorn -w 1 -b 127.0.0.1:13578 hello_gunicorn:app
命令:siege -c 1000 -r 100 -b http://127.0.0.1:13578/3344
结果:
Transactions: 57354 hitsAvailability: 96.91 %Elapsed time: 188.50 secsData transferred: 2.24 MBResponse time: 0.41 secsTransaction rate: 304.27 trans/secThroughput: 0.01 MB/secConcurrency: 124.78Successful transactions: 57354Failed transactions: 1831Longest transaction: 85.62Shortest transaction: 0.00
tornado
命令:siege -c 1000 -r 100 -b http://127.0.0.1:13577/3344
结果:
Transactions: 217509 hitsAvailability: 99.42 %Elapsed time: 205.48 secsData transferred: 8.50 MBResponse time: 0.34 secsTransaction rate: 1058.54 trans/secThroughput: 0.04 MB/secConcurrency: 356.45Successful transactions: 217509Failed transactions: 1266Longest transaction: 89.39Shortest transaction: 0.03
gevent
命令:siege -c 1000 -r 100 -b http://127.0.0.1:13576/3344
结果:
Transactions: 999952 hitsAvailability: 100.00 %Elapsed time: 509.62 secsData transferred: 39.10 MBResponse time: 0.48 secsTransaction rate: 1962.15 trans/secThroughput: 0.08 MB/secConcurrency: 935.08Successful transactions: 999952Failed transactions: 48Longest transaction: 63.23Shortest transaction: 0.02
twisted
命令:twistd -n web --port 13575 --wsgi hello_twised.app
命令:siege -c 1000 -r 100 -b http://127.0.0.1:13575/3344
结果:
Transactions: 155276 hitsAvailability: 99.14 %Elapsed time: 321.25 secsData transferred: 6.07 MBResponse time: 0.77 secsTransaction rate: 483.35 trans/secThroughput: 0.02 MB/secConcurrency: 371.09Successful transactions: 155276Failed transactions: 1340Longest transaction: 83.32Shortest transaction: 0.04
————————————————
版权声明:本文为CSDN博主「peter-广」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/marscrazy_90/java/article/details/41943211