SoFunction
Updated on 2024-11-21

python commonly used web framework simple performance test results to share (including django, flask, bottle, tornado)

Measured the performance of django, flask, bottle, tornado framework itself in the simplest way. I'm completely speechless about django's performance.

django, flask, bottle all use gunicorn + gevent start, single process, and close the DEBUG, the request only return a string ok.

tornado starts directly by itself, everything else is consistent.

The test software is siege, the test os is cenos6 64 bit, and the test command is.

Copy Code The code is as follows.

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

The django test results are.
Copy Code The code is as follows.

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

The django (with all middleware removed) test results are.
Copy Code The code is as follows.

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

The results of the flask test are.
Copy Code The code is 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 results of the Bottle test are.
Copy Code The code is 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

The tornado test results are.
Copy Code The code is 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

The performance of the pure frame itself can be seen to be.
Copy Code The code is as follows.

bottle > flask > tornado > django

Used in conjunction with.

tornado uses an asynchronous driver, so writing business code that is slightly synchronized with time-consuming performance can degrade dramatically;
There are so many things that Bottle needs to implement itself, and I don't know what the performance will be like when it's added;
flask is slightly less performant, but the surrounding support is already rich;
The only good thing about django is that the development framework is already in place and development is much faster!

Since I was recently worried about selecting a model for a project, I measured it, so let's document it here.

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