[Python] Serving Python (Flask) REST API over HTTP2

Discussão em 'Python' iniciado por Stack, Setembro 6, 2025.

  1. Stack

    Stack Membro Participativo

    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 redirects to port 443) is running as a reverse proxy and forwards requests to Gunicorn (port 8000, no SSL). nginx is running in HTTP2 mode and I can verify that by using chrome and inspecting the 'protocol' column after sending a simple GET to the server. However, Gunicorn reports that the requests it receives are HTTP1.0. Also, I coulnt't find it in this list: https://github.com/http2/http2-spec/wiki/Implementations So, my questions are:

    • Is it possible to serve a Python (Flask) application with HTTP2? If yes, which servers support it?
    • In my case (one reverse proxy server and one serving the actual API), which server has to support HTTP2?

    The reason I want to use HTTP2 is because in some cases I need to perform thousands of requests all together and I was interested to see if the multiplexed requests feature of HTTP2 can speed things up. With HTTP1.0 and Python Requests as the client, each request takes ~80ms which is unacceptable. The other solution would be to just bulk/batch my REST resources and send multiple with a single requests. Yes, this idea sounds just fine, but I am really interested to see if HTTP2 could speed things up.

    Finally, I should mention that for the client side I use Python Requests with the Hyper http2 adapter.

    Continue reading...

Compartilhe esta Página