fastapi和php,Sanic vs Fastapi 性能对比

Sanic , Fastapi都是优秀的python web异步框架,找了半天没找到靠谱的性能对比测试,只能自己做一个。

测试内容:纯get请求、异步ORM读

测试工具:WRK

测试代码:由于两者代码非常相似,本文就直接放上fastapi的代码demo了。

1、纯get请求 压测:

1.1 :代码

fastapi和php,Sanic vs Fastapi 性能对比_第1张图片

代码demo

1.2 : 结果

1.2.1 Sanic

Running 30s test @ http://0.0.0.0:7006/

4 threads and 1000 connections

Thread Stats  Avg      Stdev    Max  +/- Stdev

Latency    6.26ms    5.01ms  82.78ms  85.31%

Req/Sec    9.85k    7.36k  23.68k    50.08%

Latency Distribution

50%    4.27ms

75%    7.64ms

90%  13.17ms

99%  24.40ms

1176945 requests in 30.08s, 126.83MB read

Socket errors: connect 751, read 25, write 0, timeout 0

你可能感兴趣的:(fastapi和php)