Django,Tornado,Flask性能測試比較

Django性能測試

1000的情況下

Concurrency Level:      500
Time taken for tests:   3.009 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      1915000 bytes
HTML transferred:       1767000 bytes
Requests per second:    332.30 [#/sec] (mean)
Time per request:       1504.655 [ms] (mean)
Time per request:       3.009 [ms] (mean, across all concurrent requests)
Transfer rate:          621.44 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   94 291.0      0    1000
Processing:    14  112 315.5     22    2007
Waiting:        7  108 315.8     19    2006
Total:         14  206 583.2     22    3004

Percentage of the requests served within a certain time (ms)
  50%     22
  66%     24
  75%     25
  80%     27
  90%    219
  95%   2006
  98%   2412
  99%   2607
 100%   3004 (longest request)

5000就很吃力了

Concurrency Level:      500
Time taken for tests:   68.403 seconds
Complete requests:      4651
Failed requests:        0
Total transferred:      8906665 bytes
HTML transferred:       8218317 bytes
Requests per second:    67.99 [#/sec] (mean)
Time per request:       7353.535 [ms] (mean)
Time per request:       14.707 [ms] (mean, across all concurrent requests)
Transfer rate:          127.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   91 447.6      0    7011
Processing:    13  528 4209.0     22   52579
Waiting:        4  526 4208.8     20   52579
Total:         13  619 4453.8     22   55584

Percentage of the requests served within a certain time (ms)
  50%     22
  66%     23
  75%     24
  80%     25
  90%     28
  95%   1020
  98%   7230
  99%  17066
 100%  55584 (longest request)

Tornado性能測試

1000的情況

Concurrency Level:      500
Time taken for tests:   0.622 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      205000 bytes
HTML transferred:       12000 bytes
Requests per second:    1606.50 [#/sec] (mean)
Time per request:       311.236 [ms] (mean)
Time per request:       0.622 [ms] (mean, across all concurrent requests)
Transfer rate:          321.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    2   3.9      0      13
Processing:     2   77  22.4     76     282
Waiting:        2   77  22.4     76     282
Total:         14   79  22.0     76     282

Percentage of the requests served within a certain time (ms)
  50%     76
  66%     81
  75%     82
  80%     82
  90%     84
  95%     95
  98%    167
  99%    170
 100%    282 (longest reques

5000的情況

Concurrency Level:      500
Time taken for tests:   3.877 seconds
Complete requests:      5000
Failed requests:        0
Total transferred:      1025000 bytes
HTML transferred:       60000 bytes
Requests per second:    1289.54 [#/sec] (mean)
Time per request:       387.734 [ms] (mean)
Time per request:       0.775 [ms] (mean, across all concurrent requests)
Transfer rate:          258.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   61 238.2      0    1001
Processing:     2  201 522.7     75    2866
Waiting:        2  201 522.7     75    2866
Total:         17  262 750.6     75    3866

Percentage of the requests served within a certain time (ms)
  50%     75
  66%     76
  75%     78
  80%     80
  90%     90
  95%   3003
  98%   3811
  99%   3841
 100%   3866 (longest request)

10000就掛了

Flask測試

1000的情況刷后,到999就死了

Concurrency Level:      500
Time taken for tests:   0.668 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      166000 bytes
HTML transferred:       12000 bytes
Requests per second:    1496.62 [#/sec] (mean)
Time per request:       334.087 [ms] (mean)
Time per request:       0.668 [ms] (mean, across all concurrent requests)
Transfer rate:          242.62 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   1.4      0       5
Processing:     1   66  23.0     68     518
Waiting:        1   66  22.9     68     518
Total:          6   66  22.4     68     522

Percentage of the requests served within a certain time (ms)
  50%     68
  66%     69
  75%     69
  80%     70
  90%     72
  95%     73
  98%     74
  99%     74
 100%    522 (longest request)

5000情況下

Concurrency Level:      500
Time taken for tests:   4.441 seconds
Complete requests:      4677
Failed requests:        0
Total transferred:      776382 bytes
HTML transferred:       56124 bytes
Requests per second:    1053.15 [#/sec] (mean)
Time per request:       474.764 [ms] (mean)
Time per request:       0.950 [ms] (mean, across all concurrent requests)
Transfer rate:          170.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   10  98.7      0    1003
Processing:     1   62  72.8     56    1058
Waiting:        1   62  72.8     56    1057
Total:          8   72 162.9     56    2058

Percentage of the requests served within a certain time (ms)
  50%     56
  66%     57
  75%     57
  80%     57
  90%     58
  95%     58
  98%     64
  99%    480
 100%   2058 (longest request)

測試的代碼:
Django:
直接使用

django-admin startproject django_test
python manage.py startapp app_test'
python manage.py migrate
python manage runserver

Tornado

#!/usr/bin/env python3
# coding=utf-8

import tornado.ioloop
import tornado.web


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")


def make_app():
    return tornado.web.Application([
        (r"/", MainHandler),
    ])

if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

Flask

#!/usr/bin/env python3
# coding=utf-8

from flask import Flask
import logging
app = Flask(__name__)

log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)


@app.route('/')
def hello_world():
    return 'Hello World!'

if __name__ == '__main__':
    app.run(port=8888, debug=False)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末冗澈,一起剝皮案震驚了整個濱河市该面,隨后出現(xiàn)的幾起案子啤覆,更是在濱河造成了極大的恐慌帐要,老刑警劉巖怠李,帶你破解...
    沈念sama閱讀 218,451評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異朱庆,居然都是意外死亡盛泡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,172評論 3 394
  • 文/潘曉璐 我一進店門椎工,熙熙樓的掌柜王于貴愁眉苦臉地迎上來饭于,“玉大人,你說我怎么就攤上這事维蒙£溃” “怎么了?”我有些...
    開封第一講書人閱讀 164,782評論 0 354
  • 文/不壞的土叔 我叫張陵颅痊,是天一觀的道長殖熟。 經(jīng)常有香客問我,道長斑响,這世上最難降的妖魔是什么菱属? 我笑而不...
    開封第一講書人閱讀 58,709評論 1 294
  • 正文 為了忘掉前任,我火速辦了婚禮舰罚,結(jié)果婚禮上纽门,老公的妹妹穿的比我還像新娘。我一直安慰自己营罢,他們只是感情好赏陵,可當我...
    茶點故事閱讀 67,733評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著饲漾,像睡著了一般蝙搔。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上考传,一...
    開封第一講書人閱讀 51,578評論 1 305
  • 那天吃型,我揣著相機與錄音,去河邊找鬼僚楞。 笑死勤晚,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的镜硕。 我是一名探鬼主播运翼,決...
    沈念sama閱讀 40,320評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼兴枯!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起矩欠,我...
    開封第一講書人閱讀 39,241評論 0 276
  • 序言:老撾萬榮一對情侶失蹤财剖,失蹤者是張志新(化名)和其女友劉穎悠夯,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體躺坟,經(jīng)...
    沈念sama閱讀 45,686評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡沦补,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,878評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了咪橙。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片夕膀。...
    茶點故事閱讀 39,992評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖美侦,靈堂內(nèi)的尸體忽然破棺而出产舞,到底是詐尸還是另有隱情,我是刑警寧澤菠剩,帶...
    沈念sama閱讀 35,715評論 5 346
  • 正文 年R本政府宣布易猫,位于F島的核電站,受9級特大地震影響具壮,放射性物質(zhì)發(fā)生泄漏准颓。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,336評論 3 330
  • 文/蒙蒙 一棺妓、第九天 我趴在偏房一處隱蔽的房頂上張望攘已。 院中可真熱鬧,春花似錦怜跑、人聲如沸样勃。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,912評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽彤灶。三九已至,卻和暖如春批旺,著一層夾襖步出監(jiān)牢的瞬間幌陕,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,040評論 1 270
  • 我被黑心中介騙來泰國打工汽煮, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留搏熄,地道東北人。 一個月前我還...
    沈念sama閱讀 48,173評論 3 370
  • 正文 我出身青樓暇赤,卻偏偏與公主長得像心例,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子鞋囊,可洞房花燭夜當晚...
    茶點故事閱讀 44,947評論 2 355

推薦閱讀更多精彩內(nèi)容