Serving Python (Flask) REST API over HTTP2

后端 未结 2 1347
迷失自我
迷失自我 2021-02-04 01:32

I have a Python REST service and I want to serve it using HTTP2. My current server setup is nginx -> Gunicorn. In other words, nginx (port 443 and 80 that redire

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-04 01:51

    It is now possible to serve HTTP/2 directly from a Python app, for example using Twisted. You asked specifically about a Flask app though, in which case I'd (with bias) recommend Quart which is the Flask API reimplemented on top of asyncio (with HTTP/2 support).

    Your actual issue,

    With HTTP1.0 and Python Requests as the client, each request takes ~80ms

    suggests to me that the problem you may be experiencing is that each request opens a new connection. This could be alleviated via the use of a connection pool without requiring HTTP/2.

提交回复
热议问题