How does CloudRun in GCP coverts http 1.1 to http 2 for flask application

230 views Asked by At

We have API's that are written in Flask application and by default flask only supports http 1.1 unless we use some reverse proxy like Nginx. I was experimenting to check if Classic Application Load balancer could act as a reverse proxy for our use cause so that we could directly use flask application on Gunicorn and then deploy it on a CloudRun. Then this CloudRun is used as a backend for a HTTPS Classic LoadBalancer.

When docker image was ran locally I could see that the API's were using http 1.1 protocol but when it was deployed on Load balancer I could see that it was using http 2 protocol. Then I checked the http resource from the Cloudrun instance and the API's were using http 2 protocol. How does this actually get converted from http1.1 to http2? Can someone help me understand this mechanism ?

Image 1 is deployed in Local Local deployment of

Image 2 is deployed in HTTP Classic load balancer without CDN Deployed on the Load balancer

Image 3 is deployed on CloudRun Deployed on Cloudrun

1

There are 1 answers

6
John Hanley On BEST ANSWER

HTTP 1.1 is not converted to HTTP 2. The client includes an upgrade header in the request. If the server supports HTTP 2, it responds with a “101 Switching” status and then uses HTTP 2 on that connection.

More details are provided here.

Cloud Run HTTP 2 Details:

For Cloud Run services, Cloud Run by default downgrades HTTP/2 requests to HTTP/1 when those requests are sent to the container. If you want to explicitly set your service to use HTTP/2 end-to-end, with no such downgrading, you can configure it for HTTP/2.

Cloud Run: Using HTTP/2 (services)