BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Google Updates Its Cloud Run Service Support for WebSockets, HTTP/2, and gRPC Bidirectional Streams

Google Updates Its Cloud Run Service Support for WebSockets, HTTP/2, and gRPC Bidirectional Streams

This item in japanese

Bookmarks

In a recent blog post, Google announced a set of traffic serving capabilities for Cloud Run: end-to-end HTTP/2 connections, WebSockets support, and gRPC bidirectional streaming, completing the types of RPCs that are offered by gRPC. All of them are now in public preview for all Cloud Run locations. With these capabilities, developers can deploy and run a wider variety of web services and APIs to Cloud Run.  

Cloud Run is a managed compute platform that enables developers to run stateless containers invocable via web requests or Pub/Sub events. It is serverless, meaning all infrastructure management is abstract away, and developers can focus more on building applications.

The initial release of Cloud Run did not support streaming as it buffered both the request from the client and the service’s response. However, last year in October, the company announced server-side streaming support, which lets developers stream data from their serverless container to their clients; a development that led to new bidirectional streaming capabilities allowing developers to build and run applications that use WebSockets (e.g., social feeds, collaborative editing, multiplayer games) and the full range of gRPC bi-directional streaming APIs - both the server and the client keep exchanging data over the same request. 

Aparna Sinha, director of product, GCP Developer Platform for Serverless, Kubernetes, Anthos, stated in a tweet:


CloudRun continues to expand what you can run on serverless containers! I know many developers are writing real-time interactive apps - as part of games, social media, and consumer offerings 

To enable the streaming - client-side or bidirectional streaming with gRPC, developers need to enable HTTP/2 support.  Note that support for HTTP/2, including end-to-end HTTP/2 for gRPC, has always been present in Cloud Run since its first release - it does so by automatically upgrading clients to use the protocol. Developers can specify HTTP/2 end-to-end using the Cloud Console, the gcloud command line, or a YAML file when creating a new service or deploying a new revision. For the service to serve traffic with end-to-end HTTP/2, the application needs to handle requests with the HTTP/2 cleartext (also known as ‘h2c’) format.

gcloud beta run deploy http2-test --use-http2 --source=.


Source: https://cloud.google.com/run/docs/configuring/http2

With the updates to Cloud Run, Google continues to evolve the service with new features. The service allows running a full application in a container and will enable developers to choose their own stack to build their apps, in contrast to another cloud-managed hosting option for developers, Function as a Service (FaaS) offerings such as AWS Lambda, Azure Functions, and Google Functions – where options for developers are limited. Michael Hart, VP research engineering at Bustle Digital Group and AWS Serverless Hero, said in a tweet about the new features:

Having a connection/streaming model, as opposed to an event model, means that adding features like these are a lot easier for Cloud Run than they are for AWS Lambda.

Lastly, developers can learn more about the new capabilities through the available WebSockets demo app or the sample h2c server app. Furthermore, developers can try out Cloud Run, the free tier allowing two million requests per month, and find more details on the documentation landing page.

Rate this Article

Adoption
Style

BT