Load balancing for API Gateway

The integration of Global external Application Load Balancer and Classic Application Load Balancer support for API Gateway enables your serverless backends to take advantage of all the features provided by Cloud Load Balancing. By combining API Gateway with a global external Application Load Balancer or classic Application Load Balancer using a serverless Network Endpoint Group (serverless NEG), you can:

  • Host gateways with custom branded domains
  • Configure TLS for gateways using certificates issued by a preferred certificate authority
  • Create a common entry point for a gateway routing to multiple backends
  • Deploy gateways in multiple geographic regions for high availability without managing URLs for each region
  • Protect gateways with Cloud Armor
  • Improve gateway response time by leveraging Cloud CDN

Using a serverless NEG for API Gateway

A network endpoint group (NEG) specifies a group of backend endpoints for a load balancer. A serverless NEG is a backend that points to a Google-hosted serverless backend like Cloud Run, App Engine, or API Gateway. A serverless NEG backend for API Gateway can represent:

  • An API Gateway instance
  • A group of gateways configured with the same API config

The following figure shows how serverless NEGs can be used in the Cloud Load Balancing model:

diagram of serverless neg as backend for multi-region gateways

As illustrated in an earlier example, a backend service can be managed by several serverless NEGs. Each serverless NEG can contain a single API Gateway instance or use a URL mask to point to multiple gateways. Because all NEGs acting as a backend service are used for load balancing, they should represent functionally equivalent gateway deployments. For example, all NEGs should have the same API config deployed to each gateway in different regions. If a backend service contains several NEGs, the load balancer will balance traffic between these NEGs while minimizing request latency.

Limitations on serverless NEGs and API Gateway

A few limitations should be considered when using serverless NEGs to integrate Cloud Load Balancing for API Gateway. Most notably: