python aiohttp sancio 框架性能测试

开头先啰嗦两句:

由于本人有开发一个博客的打算,所以近期开始选型python的web框架重头学习,选了两款非常火的 aio web框架 aiohttp 和 sancio 进行性能测试以及开发喜好的调研。

经过一个多小时的努力终于不辱使命调研完成,两款框架个人更喜欢 sanic 编码方式是我喜欢的风格 支持log 性能更高 其他的还没看到 就不说了。

统一用ab测试,代码基本上一样。

测试代码: https://github.com/lminggang/asyncioDemo

使用测试代码前记得安装环境:

python3, aiohttp, sanic (python3环境自己解决一下吧,每个环境的安装方法不一样。)

pip3 install aiohttp

pip3 install sanic

以下是测试结果:

aiohttp:
ab -c 200 -n 10000 http://127.0.0.1:8080/xiaoming
Concurrency Level: 200
Time taken for tests: 3.059 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1770000 bytes
HTML transferred: 260000 bytes
Requests per second: 3269.14 [#/sec] (mean)
Time per request: 61.178 [ms] (mean)
Time per request: 0.306 [ms] (mean, across all concurrent requests)
Transfer rate: 565.08 [Kbytes/sec] received


sanic:
ab -c 200 -n 10000 http://127.0.0.1:8000/?name=xiaoming
Concurrency Level: 200
Time taken for tests: 1.011 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1250000 bytes
HTML transferred: 350000 bytes
Requests per second: 9894.81 [#/sec] (mean)
Time per request: 20.213 [ms] (mean)
Time per request: 0.101 [ms] (mean, across all concurrent requests)
Transfer rate: 1207.86 [Kbytes/sec] received

 

以上内容仅供参考。

posted @ 2019-01-08 22:47  隔壁老李的博客  阅读(932)  评论(0编辑  收藏  举报