FastAPI 上传和下载文件的基准测试
使用 FastAPI 实现了文件的上传和下载,部署服务使用了 uvicorn 和 gunicorn+uvicorn 两种方法。
基准测试工具使用的是 wrk
服务器 CPU 40核,内存 256G,操作系统 Ubuntu 20.04,Python3.9
stream 异步读取上传的文件,同步写入 tempfile.NamedTemporaryFile() 生成的文件。 http://172.16.33.159:8000/files/upload/stream/async_read_and_memory_write stream 异步读取上传的文件,同步写入磁盘文件。 http://172.16.33.159:8000/files/upload/stream/async_read_and_disk_write stream 异步读取上传的文件,异步写入磁盘文件。 http://172.16.33.159:8000/files/upload/stream/async_read_and_async_write 异步全量读取上传的文件,异步写入磁盘文件。 http://172.16.33.159:8000/files/upload/single 异步全量读取上传的文件,异步写入磁盘文件。(API 函数定义时没有使用 async) http://172.16.33.