首页 > 解决方案 > Aiohttp 性能写入大 blob?

问题描述

我正在使用 aiohttp.web.StreamResponse 来编写大型数据块(~100MB)。从功能上讲,它运行良好,但我很惊讶地看到写入性能(从构造函数到 write_eof 的测量值)达到 80MB/s 左右(客户端运行在同一台机器上和 localhost 端点)。

写代码是这样的:

     resp = StreamResponse()
     resp.headers['Content-Type'] = "application/octet-stream"
     resp.content_length = len(output_data)       
     await resp.prepare(request)
     await resp.write(output_data)
     await resp.write_eof()
  
        

这是最佳性能的最佳选择吗?什么可以限制吞吐速度?

标签: aiohttp

解决方案


推荐阅读