Home > Blockchain >  Bypassing Cloud Run 32mb error via HTTP2 end to end solution
Bypassing Cloud Run 32mb error via HTTP2 end to end solution

Time:04-01

I have an api query that runs during a post request on one of my views to populate my dashboard page. I know the response size is ~35mb (greater than the 32mb limits set by cloud run). I was wondering how I could by pass this.

My configuration is set via a hypercorn server and serving my django web app as an asgi app. I have 2 minimum instances, 1gb ram, 2 cpus per instance. I have run this docker container locally and can't bypass the amount of data required and also do not want to store the data due to costs. This seems to be the cheapest route. Any pointers or ideas would be helpful. I understand that I can bypass this via http2 end to end solution but I am unable to do so currently. I haven't created any additional hypecorn configurations. Any help appreciated!

CodePudding user response:

The Cloud Run HTTP response limit is 32 MB and cannot be increased.

One suggestion is to compress the response data. Django has compression libraries for Python or just use zlib.

import gzip
data = b"Lots of content to compress"
cdata = gzip.compress(s_in)
# return compressed data in response

CodePudding user response:

Cloud Run supports HTTP/1.1 server side streaming, which has unlimited response size. All you need to do is use chunked transfer encoding.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding

  • Related