I just deployed my application to Google Cloud Run. It has an HTTP end-point that returns a streaming response, so the client can start rendering data as it comes in instead of waiting for the response to complete (which takes ~ 10 seconds).
The response has a content-type header application/stream+json
, and the data is written to the response as separate lines. I have had this app deployed elsewhere over HTTPS and the streaming worked just fine there.
However, when deployed on Google Cloud Run the client doesn't receive any data until the response has completed.
Is this a limitation of Google Cloud Run, or is there a way I can fix this?
Cloud Run is a managed compute platform that lets you run containers directly on top of Google's scalable infrastructure. You can deploy code written in any programming language on Cloud Run if you can build a container image from it. In fact, building container images is optional. If you're using Go, Node.
You can use all gRPC types, streaming or unary, with Cloud Run. Possible use cases include: Communication between internal microservices. High loads of data (gRPC uses protocol buffers, which are up to seven times faster than REST calls).
gRPC is a compelling technology for communication between a source and target over the network. It's fast, efficient, and because it runs on HTTP/2, gRPC supports both typical request/response interactions and long-running streaming communication.
Cloud Storage supports streaming transfers, which allow you to stream data to and from your Cloud Storage account without requiring that the data first be saved to a file.
For "managed" Cloud Run, no. From https://cloud.google.com/run/docs/issues:
Cloud Run (fully managed) currently does not support HTTP streaming.
However Cloud Run on GKE does support streaming response data.
It will from Oct 2020
Cloud Run now supports server-side streaming:
https://cloud.google.com/blog/products/serverless/cloud-run-now-supports-http-grpc-server-streaming
With this addition, Cloud Run can now:
Send responses larger than the previous 32 MB limit.
Run gRPC services with server-streaming RPCs and send partial responses in a single request—in addition to existing support for unary (non-streaming) RPCs.
Respond with server-sent events (SSE), which you can consume from your frontend using the HTML5 EventSource API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With