1,简介
FastAPI是一种现代,快速(高性能)的Web框架,用于基于标准Python类型提示使用Python 3.6+构建API。
2,安装
pip install fastapi
pip install uvicorn
3,应用
3.1 main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/index")
async def index():
return "hello world"
3.2 运行
uvicorn main:app --reload
3.3 fps分析
ab -c 10 -n 10000 http://127.0.0.1:8000
部分信息
Concurrency Level: 10
Time taken for tests: 1.761 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 1380000 bytes
HTML transferred: 130000 bytes
Requests per second: 5679.08 [#/sec] (mean)
Time per request: 1.761 [ms] (mean)
Time per request: 0.176 [ms] (mean, across all concurrent requests)
Transfer rate: 765.34 [Kbytes/sec] received
fps: 5679.08 [#/sec] (mean)
4,参考文档
https://www.cnblogs.com/mazhiyong/p/12807660.html
https://blog.csdn.net/Hiking_Yu/article/details/104145437