web 部署專題(四):壓力測試(二)壓力測試實例 flask 四種wsgi方式對比(tornado,Gunicorn,Twisted,Gevent)


使用工具:siege

代碼結構:

hello.py

templates

|--hello.html

 

hello.py代碼:

from flask import Flask, render_template
app = 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 hits
Availability:               95.08 %
Elapsed time:              254.69 secs
Data transferred:            1.15 MB
Response time:                1.16 secs
Transaction rate:          115.87 trans/sec
Throughput:                0.00 MB/sec
Concurrency:              134.19
Successful transactions:       29511
Failed transactions:            1527
Longest transaction:           88.56
Shortest 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 hits
Availability:               96.91 %
Elapsed time:              188.50 secs
Data transferred:            2.24 MB
Response time:                0.41 secs
Transaction rate:          304.27 trans/sec
Throughput:                0.01 MB/sec
Concurrency:              124.78
Successful transactions:       57354
Failed transactions:            1831
Longest transaction:           85.62
Shortest transaction:            0.00

tornado

命令:siege -c 1000 -r 100 -b http://127.0.0.1:13577/3344

結果:

Transactions:              217509 hits
Availability:               99.42 %
Elapsed time:              205.48 secs
Data transferred:            8.50 MB
Response time:                0.34 secs
Transaction rate:         1058.54 trans/sec
Throughput:                0.04 MB/sec
Concurrency:              356.45
Successful transactions:      217509
Failed transactions:            1266
Longest transaction:           89.39
Shortest transaction:            0.03

gevent

命令:siege -c 1000 -r 100 -b http://127.0.0.1:13576/3344

結果:

Transactions:              999952 hits
Availability:              100.00 %
Elapsed time:              509.62 secs
Data transferred:           39.10 MB
Response time:                0.48 secs
Transaction rate:         1962.15 trans/sec
Throughput:                0.08 MB/sec
Concurrency:              935.08
Successful transactions:      999952
Failed transactions:              48
Longest transaction:           63.23
Shortest 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 hits
Availability:               99.14 %
Elapsed time:              321.25 secs
Data transferred:            6.07 MB
Response time:                0.77 secs
Transaction rate:          483.35 trans/sec
Throughput:                0.02 MB/sec
Concurrency:              371.09
Successful transactions:      155276
Failed transactions:            1340
Longest transaction:           83.32
Shortest transaction:            0.04

————————————————
版權聲明:本文為CSDN博主「peter-廣」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/marscrazy_90/java/article/details/41943211


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM