1. 程式人生 > >python aiohttp sancio 框架性能測試

python aiohttp sancio 框架性能測試

好的 rate 代碼 選型 request 開頭 風格 aio time

開頭先啰嗦兩句:

由於本人有開發一個博客的打算,所以近期開始選型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

以上內容僅供參考。

python aiohttp sancio 框架性能測試