
Summary
Key points of this document
- LB backend service reaches limit before service splitting
- No new solutions will be established; instead, align with the two existing shared entry points.
- The static gateway determines the delivery destination from the Host, hiding the number of tenants from the LB.
Overview
Even if Cloud Run is split into smaller services, if each service continues to be directly connected to a load balancer, the backend service quota will decrease proportionally to the number of services. By consolidating public access points to a static gateway and API facade and decoupling internal services from the load balancer, the unit of division and the unit of public access path can be separated. This article organizes the design, additional steps, limitations, and verification methods based on two aggregation patterns currently in operation.
LB backend service reaches limit before service splitting
Actual measurements confirmed on July 26, 2026, in the same cloud project were: GLOBALEXTERNALPROXYLBBACKENDSERVICES at 65/75, BACKENDBUCKETS at 9/9, SSLCERTIFICATES at 24/30, NETWORKENDPOINTGROUPS at 96/1000, and 155 Cloud Run services. At the start of the work, GLOBALEXTERNALPROXYLBBACKENDSERVICES were depleted to 75/75, and we reduced it to 65 by deleting 10 backend services that were not referenced by URL maps.
It is important to note here that the quota is per project, not per load balancer. Even if you create another load balancer, the limit of 75 remains shared. Also, although BACKENDSERVICES with a similar name showed 0/75, what was actually consumed in this configuration was GLOBALEXTERNALPROXYLBBACKENDSERVICES. Since the names are similar, when checking usage, we match them by metric name.
When a Cloud Run service is directly exposed to a load balancer, in addition to the service itself, one set each of serverless NEG, backend service, and URL map path rule is added. Since the limit for backend services is 75, the more finely services are divided, the sooner the public access path limit will be reached before the application execution limit. A structural solution is to not make the service division unit and the internet exposure unit the same.
- One Cloud Run service, one NEG, one backend service, and one path rule are added for each directly exposed service.
- GLOBALEXTERNALPROXYLBBACKENDSERVICES and BACKENDSERVICES are different metrics, so do not confuse the displayed remaining capacity.
- Stop the increase in backend services by consolidating public entry points, not by adding more load balancers.
- The figures in this article are actual measurements as of July 26, 2026, and current values should be re-verified in the operational environment.
No new solutions will be established; instead, align with the two existing shared entry points.
In the confirmed environment, two patterns that save quota were already in operation. One is a static gateway for static content, and the other is a facade for APIs. Both consolidate only the number of backend services visible from the load balancer, rather than reducing services or hosts.
The static gateway runs on nginx on Cloud Run and determines the destination object storage from the Host header. In actual measurements, one backend service was serving 162 hosts. Instead of increasing Cloud Run services per tenant, it maps identifiers extracted from hostnames to bucket names.
The API facade is a method where a public API entry point implemented with Hono forwards requests to internal Cloud Run services based on the path. In actual measurements, there were 19 registrations via app.route in the entry application. Therefore, the design in this article is not a proposal for a new method, but a clarification to align the remaining exceptional direct exposures with proven patterns.
- Static delivery: Host → static gateway → object storage.
- API: Browser or external client → LB → public API entry point → internal Cloud Run service.
- Maintain Cloud Run service division, and share only the LB's backend service.
The static gateway determines the delivery destination from the Host, hiding the number of tenants from the LB.
In the static gateway, nginx's map inspects the Host, extracts the environment and tenant identifier from a regular expression, and constructs the corresponding bucket name. Even if the same tenant has multiple public hostnames, they can be resolved to the same bucket through regular expression branching. There is no need to prepare a Cloud Run service or backend bucket for each host.
This method consolidates delivery paths, not the static artifacts themselves. Build artifacts and storage locations per tenant remain separate, while only the gateway is shared. Therefore, the main change when adding is to ensure consistency between host naming conventions and bucket placement, not to increase the load balancer's backend services.
On the other hand, nginx may not be able to fully reproduce the delivery behavior of object storage. The required search order differs for SPA fallbacks and directory indexes for multi-page static sites. This constraint will be treated as a known defect described later, and not all static sites will be unconditionally moved to the gateway.
The API facade is a thin reverse proxy that forwards public paths to internal URIs.
The API flow starts from the browser or external client, enters the load balancer, passes through a common public API entry point, and proceeds to the internal Cloud Run service. The facade determines the public path, performs necessary path rewriting, and forwards HTTP methods, queries, headers, and bodies to the internal service. The destination Cloud Run URI is injected via environment variables, ensuring that environment-specific URLs are not hardcoded into the code.
This configuration can also be applied to APIs called directly from a browser. In the environments we checked, public APIs corresponding to chat, forms, media, orders, inquiries, learning, and administration screens were already operating via the facade. The premise that 'browser-facing APIs must be individually placed on the LB' does not hold true.
By attaching a unique query marker to the health endpoint of the public inquiry API and cross-referencing the public-side response with the internal Cloud Run request logs, we confirmed that a 200 response was returned via the path: LB, public API entry point, HTTP proxy, and internal service. Even without a path rule for the internal service in the URL map, it can be reached via the facade. This is a fact confirmed by actual responses and logs, not by reading configurations.
- The main targets to be placed directly on the LB are limited to common public API entry points, static gateways, and special routes with individual requirements.
- Internal services receive Cloud Run URIs via environment variables and do not have public routes on the load balancer.
- Direct connection should be determined by whether a special public route is needed, not whether it is browser-facing.
Facade and BFF, though in the same application layer, have different responsibilities.
A static gateway is an infrastructure-oriented layer where Nginx selects the delivery destination based on the Host. An API facade is an application layer that runs as a Hono route, but its primary function is path rewriting and HTTP forwarding. Its purpose differs from a BFF, which aggregates multiple APIs, converts them into DTOs for screens, handles caching for display purposes, and makes screen decisions in case of partial failures.
However, the boundary is not a complete either/or. The smallest facade route we checked was a simple proxy of 59 lines, but another route was 262 lines and included authentication and response formatting. The more a facade handles authentication, aggregation, and transformation, the closer it gets to a BFF. What's important is not the name, but the ability to review whether business logic or screen-specific considerations have started to creep into that route.
If the sole purpose is quota saving, keep the facade thin. While authentication and common security measures can be placed at the entry point, the core business rules remain within the internal service. If screen-specific aggregation becomes necessary, explicitly define the responsibilities, contracts, and tests as a BFF, and do not disguise it as a mere forwarding route.
- Static gateway: Selects storage location from Host. Does not contain business logic.
- Facade: Rewrites paths and forwards to internal services. Generally does not contain business logic.
- BFF: Aggregates and formats multiple APIs, providing user-friendly contracts tailored for specific screens.
- From a thin facade to a thick facade, and then to a BFF, it's a continuous spectrum, so judgment should be based on responsibilities, not line count.
New internal services connect to the facade without creating an LB route.
When adding a new API service, first add its definition to the service manifest. Do not set publicUrl for internal-only services. Next, in the Terraform backend service definition, set pathprefixes to an empty array, excluding it from NEG and backend service generation. This conditional branching has already been implemented, ensuring that infrastructure resources are not unconditionally generated for services without pathprefixes.
Next, implement the facade route in the routes directory of the public API entry point and register it with a single line in the entry point's app.route. The destination Cloud Run URI is injected as an environment variable from Terraform. This allows the internal service itself to be deployed as an independent Cloud Run service, while external exposure can share existing backend services. Zero additional backend services are created.
Directly placing services on the LB is limited to cases with clear requirements, such as protocols not handled by common entry points, independent security boundaries, individual caching or timeouts, or fault isolation. Do not expose services directly solely 'because it's a new service.' If an exception is made, document the consumed quota and the reasons why the facade cannot be used as an alternative in the design records.
- Add service definition to ci/services.json; if internal-only, do not include publicUrl.
- Add to Terraform's backend service definition with path_prefixes = [].
- Implement facade in the routes directory for the public API entry point.
- Register the route in the entry point's app.route.
- Inject the internal Cloud Run URI as an environment variable from Terraform.
- Result: 0 additional backend services consumed.
Use common proxy helper and deployment rules as a template for additional implementations.
The deployment script has a rule that rejects deployment if publicUrl is non-empty and smokePaths is empty. If publicUrl is set for an internal service that does not have an LB path, it will be stopped as a missing public connectivity check configuration. This is not a check to be avoided, but a boundary to correctly represent the nature of the service in the manifest. Internal-only services should not have a publicUrl, and public-side smoke tests should target the facade's path.
Proxy implementation should align with existing common helpers. The confirmed helper already implemented a default 15-second internal fetch timeout and AbortController, internal API base URL resolution, forward body reading, hop-by-hop response header removal, and management API request forwarding. Rewriting the same processing for each route would lead to slight discrepancies in timeout, headers, body, and error handling.
Tests will verify method, path, query, request body, authentication header, response status, response header, and timeout. Simple proxy tests and existing media proxy tests will serve as templates. For integration tests connecting to actual services, requests with unique markers will be correlated with Cloud Run logs to confirm not only the public response but also the forwarding destination.
Standardize different timeouts and error conversions per route before expansion.
Existing routes have asymmetry. The smallest route measured uses a bare fetch and has no timeout, retry, or AbortSignal. If fetch rejects, the exception propagates outward without being converted within the route. On the other hand, thicker routes with authentication and formatting processed upstream errors with dedicated functions, maintaining 400, 403, 404, 500 while normalizing others to 502.
No registration of app.onError from the entry application was found in searches. It is possible that it is left to Hono's default error handler, but this is an inference from code search and actual exception responses have not been confirmed. It is necessary to measure status, body, and logs with actual requests and confirm along with the presence or absence of a custom handler.
If the number of routes is to be increased from 19 to 50, at least internal fetches should be standardized to a common helper with timeouts, boundaries for converting exceptions to 502 or 504, request ID propagation, and logging rules that do not expose upstream service names externally should be decided. Retries should be limited only to cases where safe methods and idempotency can be confirmed. Verify that a single slow internal service does not monopolize the common entry point's connection slots for a long time.
- Confirmed: Timeout and upstream error handling are not unified across routes.
- Unconfirmed: Actual status, body, and logs when app.onError is not present.
- Improvement decision: Consolidate timeout, AbortSignal, error mapping, and request ID into a common helper.
- Do not add retries uniformly; first confirm idempotency and the impact of duplicate execution.
Consolidating entry points also consolidates single points of failure and performance limits.
At the time of confirmation, the public API entry point had containerConcurrency 80, minScale 0, maxScale 10, timeoutSeconds 300, CPU 1, memory 512Mi, and cpu-throttling enabled. There was no drift between Terraform's declared values and the actual environment. A simple calculation yields a maximum of 80x10 = 800 concurrent connections, but this is not a performance guarantee that 800 requests can be processed stably. The effective value changes depending on internal fetch latency, CPU usage, response size, and cold start.
Since all APIs pass through the same entry point, a failure or overload at the entry point will affect multiple services. A minScale of 0 reduces standby costs while allowing for cold starts. A maxScale of 10 can also serve as an upper limit to prevent sudden loads on downstream services, but it may lengthen the queue at the entry point if the number of routes or traffic increases.
It has not yet been measured whether maxScale 10 will be sufficient for p95 and p99 of actual traffic, and when increasing from 19 routes to 50 routes. The additional 1-hop latency due to the facade has also not been measured. Before significantly increasing the number of routes, we will measure the number of requests per path, response time, 5xx errors, instance count, concurrency, and internal fetch time, and determine maxScale and timeout through load testing.
- Measured: concurrency, scaling, timeout, CPU, memory, and no Terraform drift.
- Not measured: p95/p99 of actual traffic, additional 1-hop delay, required instance count for 50 routes.
- Determine capacity not by the number of routes, but by arrival rate per path, processing time, and internal connection occupancy time.
- The more aggregation into the facade, the more important monitoring, request IDs, per-path SLOs, and fault isolation become.
SPA fallback in static gateways returns incorrect 200 for multi-page sites.
Static gateways have a known flaw. When a request is made to a non-existent path, the SPA fallback of try_files returns index.html with a status of 200. While this is the intended behavior for an SPA, it is incorrect for multi-page sites that want non-existent pages to return 404. Since 162 hosts share the same gateway, the impact of returning incorrect success responses to search engines and crawlers is also shared.
Another issue is that it does not search for index.html under directories. In the multi-page static site we checked, 144 out of 171 objects were index.html files under directories. Via the backend bucket, article paths correctly returned 200 and non-existent paths returned 404, but via the gateway, article paths returned the top page with 200, and non-existent paths also returned the top page with 200.
Due to this behavior, that multi-page site could not be migrated to the gateway and continued to use one backend bucket slot. The countermeasure is to add $uri/index.html to the try_files search order according to the nature of the content to be delivered, and to separate the conditions for applying the final SPA fallback. Backend bucket usage decreased from 9/9 before the work to 5 after migrating 4 suitable paths to the gateway, but sites with inconsistent behavior should not be migrated solely for quota savings.
- SPA: A design where unknown paths fall back to index.html is valid.
- Multi-page static sites: Explicitly define the order $uri, $uri/index.html, 404, and do not unconditionally redirect to the top page.
- For migration judgment, compare not only representative pages, but also directory indexes, assets, trailing slashes, and non-existent paths.
- The completion condition should be that the status code and body match before and after migration, not just the number of quota reductions.
Do not just read the settings, but cross-reference actual responses, logs, and entities.
During recovery work, misdiagnoses were repeated because conclusions were drawn from configuration files without measuring actual responses. We concluded that requests were not reaching the internal service because there was no rule for the public inquiry path in the URL map, but actual measurements showed they were reaching via the facade's HTTP proxy. The cause of the 404 was not the route, but an outdated container image in production.
Also, we misinterpreted the gcloud describe result of 'resource not found' as 'usedBy is empty', meaning it was not referenced. A non-existent resource is different from an existing but unreferenced resource. First, confirm the success or failure of the describe command itself, and only evaluate reference relationships for resources that successfully described.
In an example where a backend bucket not referenced by the URL map was almost deemed unnecessary, it was defined in the Terraform config without conditions, but the apply did not complete due to quota overage. Unreferenced and unapplied are also different. Compare the three: config, Terraform state, and live resource, to identify at which stage the discrepancy occurred.
For path validation, we don't stop at a successful curl. We attach a unique query marker or request ID and trace the same request in the ingress and destination logs. For static delivery, we compare not only the status code but also the body content. The evidence is not that the inspection side's settings look correct, but that the actual response of the path taken by the user is as expected.
- Path: Match curl, unique marker, ingress log, and destination log for a single request.
- Resource: After confirming the success of 'describe', read 'usedBy' and reference relationships.
- IaC: Compare config, state, and live to distinguish between undefined, unapplied, and unreferenced.
- Static delivery: Check not only for 200, but also if it's the expected HTML and if unknown paths return 404.
Share public entry points and isolate only exceptions in a measurable way.
There is no need to have a one-to-one correspondence between Cloud Run service divisions and the number of load balancer backend services. Regular static delivery is aggregated to a static gateway, regular HTTP APIs to a facade, and internal services maintain independent deployment, scaling, logging, and permissions. This allows for 0 LB quota consumption even if you increase the number of services.
However, entry point aggregation is not free. On the API side, you manage single points of failure, concurrency, timeout, error mapping, and additional hops, while on the static side, you separate delivery rules for SPAs and multi-page sites. If special protocols, independent security boundaries, or individual caching, SLOs, and fault isolation are required, it may be better to have a direct backend service.
The practical decision criterion is not whether it's called from a browser, but whether the shared entry point can forward without changing the contract. If forwarding is sufficient, use a facade; if the destination can be determined from the Host, use a static gateway; if aggregation/formatting for the screen is needed, use a BFF; only choose a direct LB when non-functional requirements cannot be met by a shared entry point. By documenting these decisions and actual measurement results, we can prevent quota savings from being replaced by new performance issues or misdeliveries.


