对比 FastAPI Robyn Gin json 序列化返回性能 大概的性能对比如下
wrk -t10 -c 10 -d 20s http://127.0.0.1:xxxx/json
FastAPI (async)
Running 20s test @ http://127.0.0.1:8080/json
10 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 835.68us 798.76us 29.00ms 94.21%
Req/Sec 1.32k 513.33 2.51k 49.45%
262867 requests in 20.10s, 38.10MB read
Requests/sec: 13078.90
Transfer/sec: 1.90MB
Robyn (sync)
Running 20s test @ http://127.0.0.1:8111/json
10 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 358.51us 690.23us 24.51ms 96.09%
Req/Sec 3.91k 1.70k 9.80k 76.79%
781679 requests in 20.10s, 75.29MB read
Requests/sec: 38889.89
Transfer/sec: 3.75MB
Robyn (async)
Running 20s test @ http://127.0.0.1:8111/json
10 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 517.35us 795.62us 32.63ms 95.72%
Req/Sec 2.42k 0.87k 6.79k 71.78%
481576 requests in 20.10s, 46.39MB read
Requests/sec: 23959.48
Transfer/sec: 2.31MB
Gin
Running 20s test @ http://127.0.0.1:8888/json
10 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 293.92us 688.32us 27.60ms 94.13%
Req/Sec 6.87k 2.66k 13.32k 58.32%
1368505 requests in 20.10s, 195.77MB read
Requests/sec: 68090.01
Transfer/sec: 9.74MB
robyn 基准参考 https://github.com/sansyrox/robyn-comparison-benchmarks
Rust+Python Python 的下一波春天?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.