Challenges with hosting a gRPC Server in GCP


by Pankaj Swami


With its ease of use, zero server management, and zero configuration deployment, App Engine is one of the most commonly used serverless options in the GCP ecosystem.


In one microservice-based project, we used gRPC for internal communication between microservices. In the process of deploying our microservices on App Engine after development is complete, we encountered some issues.

The following is how we identified the problem and found an alternative solution.

Why doesn’t gRPC work on App Engine?

Even though they work differently internally, there are almost the same reasons why gRPC doesn't work in both types of App Engines, but before we can understand this, we need to know how they work.

How exactly does the App Engine Work?

1. Standard Environment

The App Engine standard environment is based on container instances running on Google's infrastructure. Containers are preconfigured with one of several available runtimes.

Applications run in a secure, sandboxed environment, allowing the standard environment to distribute requests across multiple servers and scale servers to meet traffic demands.

Your application runs within its own secure, reliable environment that is independent of the hardware, operating system, or physical location of the server.

2. Flexible Environment

The App Engine Flex is a Docker container running on top of Google Compute Engine.

Based on Compute Engine, the App Engine flexible environment automatically scales your app up and down while also balancing the load.

The main reason, why gRPC support is not available for App Engine as yet, is related to the presence of the load balancer. In fact one may say that gRPC would be supported, were it not for the fact that the GAE load balancer prevents such requests to reach the instances

Routing the remote procedure calls in GAE is very difficult and the actual reason why it's not working.

What are the alternate options (serverless) available in GCP to host a gRPC server?

Option 1 (Only for Python 2.7 & Java 8 runtime environments):

You can still run a gRPC server on an App Engine Standard environment using Cloud Endpoint Frameworks & Extensible Service Proxy (ESP)

The ESP provides API management features for Endpoints for OpenAPI and Endpoints for gRPC. ESP runs in a container alongside each instance of your backend.

Because the App Engine standard environment didn't support multi-container deployments when Endpoints Frameworks was under development, Endpoints Frameworks doesn't use ESP. Instead, Endpoints Frameworks includes a built-in API gateway that provides API management features that are comparable to the features that ESP provides for Endpoints for OpenAPI and Endpoints for gRPC.

Option 2 - Cloud Run:

Cloud Run is a managed compute platform that lets you run containers directly on top of Google's scalable infrastructure.

A gRPC server can be run on Cloud Run, unlike GAE Flex, because the user has total control over the containers using Dockerfile.

This will help you set up your gRPC server in the Cloud Run.

Read More


If you have a technical challenge, we would love to hear about it.