Django, Tornado, Flask 성능 테스트 비교

6418 단어
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)

좋은 웹페이지 즐겨찾기