python常用web框架简单性能测试结果分享(包含django、flask、bottle、tornado)
程序员文章站
2022-03-10 21:15:27
...
测了一下django、flask、bottle、tornado 框架本身最简单的性能。对django的性能完全无语了。
django、flask、bottle 均使用gunicorn+gevent启动,单进程,并且关闭DEBUG,请求均只返回一个字符串ok。
tornado直接自己启动,其他内容一致。
测试软件为 siege,测试os为cenos6 64位,测试命令为:
复制代码 代码如下:
siege -c 100 -r 100 -b http://127.0.0.1:5000/
django测试结果为:
siege -c 100 -r 100 -b http://127.0.0.1:5000/
django测试结果为:
复制代码 代码如下:
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(去掉所有middleware)测试结果为:
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(去掉所有middleware)测试结果为:
复制代码 代码如下:
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测试结果为:
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测试结果为:
复制代码 代码如下:
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
bottle测试结果为:
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
bottle测试结果为:
复制代码 代码如下:
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测试结果为:
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测试结果为:
复制代码 代码如下:
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
可见纯框架自身的性能为:
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
可见纯框架自身的性能为:
复制代码 代码如下:
bottle > flask > tornado > django
结合实际使用:
bottle > flask > tornado > django
结合实际使用:
tornado 使用了异步驱动,所以在写业务代码时如果稍有同步耗时性能就会急剧下降;
bottle需要自己实现的东西太多,加上之后不知道性能会怎样;
flask性能稍微差点,但周边的支持已经很丰富了;
django就不说了,性能已经没法看了,唯一的好处就是开发的架子都已经搭好,开发速度快很多
因为最近正在为一个项目选型发愁,所以就测了一下,记录在此吧。
PS: 2014-6-23 使用 centos6 64位 重新进行了测试,得出与生产环境更匹配的结果,并修改了文章。
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
上一篇: java如何获取文件路径
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论