Python common web framework simple performance test results share of django flask bottle tornado

  • 2020-04-02 14:00:23
  • OfStack

The simplest performance of django, flask, bottle, tornado framework itself was tested. There is absolutely no word on django's performance.

Django, flask, and bottle were all started with gunicorn+gevent, single process, and turned off DEBUG, all requests returned a string of ok.

Tornado directly started on its own, other content is the same.

The test software is siege, the test OS is cenos6 64-bit, and the test command is:


siege -c 100 -r 100 -b http://127.0.0.1:5000/

The django test results are:

Transactions:               10000 hits
Availability:              100.00 %
Elapsed time:               18.51 secs
Data transferred:            0.02 MB
Response time:                0.18 secs
Transaction rate:          540.25 trans/sec
Throughput:                0.00 MB/sec
Concurrency:               99.35
Successful transactions:       10000
Failed transactions:               0
Longest transaction:            0.30
Shortest transaction:            0.12

Django (remove all middleware) test results were:

Transactions:               10000 hits
Availability:              100.00 %
Elapsed time:               12.97 secs
Data transferred:            0.02 MB
Response time:                0.13 secs
Transaction rate:          771.01 trans/sec
Throughput:                0.00 MB/sec
Concurrency:               99.41
Successful transactions:       10000
Failed transactions:               0
Longest transaction:            0.28
Shortest transaction:            0.12

Flask test results are as follows:

Transactions:               10000 hits
Availability:              100.00 %
Elapsed time:                5.47 secs
Data transferred:            0.02 MB
Response time:                0.05 secs
Transaction rate:         1828.15 trans/sec
Throughput:                0.00 MB/sec
Concurrency:               96.25
Successful transactions:       10000
Failed transactions:               0
Longest transaction:            0.11
Shortest transaction:            0.00

The test results of bottle are as follows:

Transactions:               10000 hits
Availability:              100.00 %
Elapsed time:                4.55 secs
Data transferred:            0.02 MB
Response time:                0.04 secs
Transaction rate:         2197.80 trans/sec
Throughput:                0.00 MB/sec
Concurrency:               96.81
Successful transactions:       10000
Failed transactions:               0
Longest transaction:            0.09
Shortest transaction:            0.00

Tornado test results are as follows:

Transactions:               10000 hits
Availability:              100.00 %
Elapsed time:                7.06 secs
Data transferred:            0.02 MB
Response time:                0.07 secs
Transaction rate:         1416.43 trans/sec
Throughput:                0.00 MB/sec
Concurrency:               99.51
Successful transactions:       10000
Failed transactions:               0
Longest transaction:            0.09
Shortest transaction:            0.01

It can be seen that the performance of the pure framework itself is:

bottle > flask > tornado > django

Combined with practical use:

Tornado USES an asynchronous driver, so when writing business code, performance drops dramatically if there is a small synchronization time;
Bottle has too much to implement on its own, plus it doesn't know what the performance will be;
Flask's performance is a little bit worse, but the support surrounding it is already quite extensive;
Forget django, the performance is unreadable, and the only benefit is that the development racks are set up and development is much faster

I have been worrying about the selection of a project recently, so I have measured it and recorded it here.

PS: 2014-6-23 re-tested with centos6 64 bit to get a better match with the production environment, and modified the article.


Related articles: