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)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,980评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,178评论 2 380
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,868评论 0 336
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,498评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,492评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,521评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,910评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,569评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,793评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,559评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,639评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,342评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,931评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,904评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,144评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,833评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,350评论 2 342

推荐阅读更多精彩内容