Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Google Cloud Run support streaming response data?

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?

like image 621
Rob van Maris Avatar asked Nov 21 '19 16:11

Rob van Maris


People also ask

What is Google Cloud run used for?

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.

Does cloud run support gRPC?

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).

Is gRPC good for streaming data?

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.

Can you stream from cloud storage?

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.


2 Answers

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.

like image 184
Dustin Ingram Avatar answered Sep 30 '22 13:09

Dustin Ingram


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.

like image 29
Bala.Raj Avatar answered Sep 30 '22 13:09

Bala.Raj