How the split shows up in the connection table#
A Cloud Run service shifting traffic with gcloud run services update-traffic SERVICE --to-revisions REVISION=PERCENTAGE runs two revisions side by side. The new one starts instances for its share, and the old one does not drop its instances at the moment its share falls. Requests leave it, but Cloud Run may keep instances idle for up to 15 minutes after they finish handling requests, and an idle instance can keep resources such as open database connections. Gradual rollouts · Idle instances
The database sees the sum. PostgreSQL then refuses new sessions with SQLSTATE 53300, which reaches the revision that is opening connections: usually the new one, since its instances are the ones starting. That makes the new revision look broken when the table filled because two revisions shared it. This is the admission stage of the four stages.
Three settings change how many instances can coexist:
- A service-level maximum is divided among the revisions that receive traffic, in proportion to their share, so a revision can hit its effective maximum while the service has not. A revision-level maximum applies to each revision on its own, so the service total can exceed it during a split. Maximum instances and traffic splits
- When a deploy sends 100% of traffic to a new revision at once, Cloud Run starts enough instances of the new revision before directing traffic to it, so the overlap happens there too. Deployments
- Revision-level minimum instances start whenever the revision is referenced in a traffic split or has a tag, and stay up with no requests. A tagged old revision with a revision-level minimum holds its pools indefinitely. Minimum instances and tags
A split set once stays in place: later deploys keep that traffic pattern until all traffic goes to the latest revision. Lifecycle of traffic splits
Check 1: line up the traffic steps with the first refusal#
Cloud Run logs each instance start in varlog/system, with the reason DEPLOYMENT_ROLLOUT for instances started by traffic shifting between revisions, a split adjustment or a deployment health check. Read those starts beside the first database refusals: Instance scaling logs
gcloud logging read \
'resource.type="cloud_run_revision"
AND resource.labels.service_name="SERVICE"
AND timestamp>="START_TIME"
AND (textPayload:"Starting new instance" OR textPayload:"53300" OR jsonPayload.message:"53300")' \
--project PROJECT --order=asc --limit=300 \
--format='value(timestamp, resource.labels.revision_name, labels.instanceId, textPayload, jsonPayload.message)'
Whether the SQLSTATE appears in the text depends on the driver and on how the application logs errors; search for the driver's wording if the code is missing. Then read the configured split:
gcloud run services describe SERVICE \
--project PROJECT --region REGION \
--format='yaml(metadata.annotations, status.traffic)'
status.traffic lists each revision with its percentage and tag; run.googleapis.com/maxScale among the service's annotations is the service-level maximum. Service status · Annotations
If the first refusal follows a traffic step within minutes and the two revisions' DEPLOYMENT_ROLLOUT starts cluster around it, continue. If the refusals began before the step, read the budget for a single revision.
Check 2: count instances and sessions per revision#
Chart Cloud Run's container/instance_count for the window, grouped by revision_name and state. The metric splits instances into active and idle, so you can see how many old instances stayed up idle after the step. Beside it, chart Cloud SQL's database/postgresql/num_backends_by_application, which counts connections grouped by application, sampled every 60 seconds. Both keep history, so they work after the incident. Cloud Run metrics · Cloud SQL metrics
Grouping by application tells revisions apart only if each revision names its connections. Which revision holds the connections shows how to set application_name from K_REVISION and how to count without it.
Divide each revision's sessions by its instance count, then read the result:
| At the first refusal | Sessions per instance | Reading |
|---|---|---|
| Old and new sessions together reach the usable slots; each revision alone fits | About equal in both revisions | The split's overlap filled the table. The old revision's instances, many idle, still held their pools |
| Same | Clearly higher in the new revision | The release changed how many connections an instance opens: pool size, workers per instance, or a connection opened per request. It fails at full traffic too |
| Neither revision's sessions rose at the step | Unchanged | Not the split. Look at the other clients' sessions in the same minutes |
What to do with each reading#
For the overlap, plan each step against the sum: old revision's instances, including idle ones, plus the new revision's instances at its share, times the per-instance limit, plus other clients. Smaller steps add fewer new instances at once. A service-level maximum caps the two revisions together, since it is divided between them. A smaller pool per instance leaves room for both. The old revision's idle instances go away within 15 minutes of their last request unless a minimum keeps them, so the overlap is temporary; a tag with a revision-level minimum makes it permanent.
For a release that opens more per instance, routing traffic back to the old revision removes the cause. Fix the pool or worker change before the next attempt, and recompute the full-traffic budget.
A worked fixture: one error at a split, two causes#
The fixture is illustrative. orders-api connects to orders-db, which has 397 usable slots; orders-worker and analysts hold 22. Each instance of orders-api runs one pool of 10 connections and names its connections from K_REVISION. Each revision carries autoscaling.knative.dev/maxScale: '30', and the service sets no service-level maximum. orders-api-00017 serves all traffic with 24 instances and 240 sessions.
Split A, 2026-11-18. At 10:00:00 UTC the team runs update-traffic --to-revisions orders-api-00018=50. By 10:01, varlog/system shows 15 DEPLOYMENT_ROLLOUT starts for orders-api-00018. orders-api-00017 still has 24 instances, 12 of them idle.
| Time (UTC) | orders-api-00017 sessions | orders-api-00018 sessions | Other | Total |
|---|---|---|---|---|
| 09:59 | 240 | 0 | 22 | 262 |
| 10:01:30 | 240 | 135 | 22 | 397 |
| 10:16 | 130 | 150 | 22 | 302 |
At 10:01:42 the first 53300 appears on a new orders-api-00018 instance. Per instance, orders-api-00017 holds 240 / 24 = 10 and orders-api-00018 holds 135 / 15 = 9: the same pool, and its newest instances not yet full. By 10:16 the old revision is down to 13 instances and the total has room. The split caused the error. The next step goes to 100% only after the old revision's idle instances have drained, with a service-level maximum of 30, which holds the revisions taking traffic near 300 pooled connections. Idle old instances and Cloud Run's brief excess above the maximum come on top of that. Maximum instances · Instance autoscaling
Split B, 2026-11-20. At 15:00:00 UTC, orders-api-00019 gets 10%. At 15:02:10, 53300 errors begin on orders-api-00019.
| Time (UTC) | orders-api-00017 sessions | orders-api-00019 sessions | Other | Total |
|---|---|---|---|---|
| 15:02 | 220 (22 instances) | 155 (4 instances) | 22 | 397 |
The old revision holds 10 per instance; the new one holds nearly 39, and its fourth instance was still being refused when the table filled. The release raised the web server's workers from one to four, each with its own pool of 10: 40 per instance. At full traffic, 22 instances would want 880. Route traffic back to orders-api-00017, then fix the pool before rolling forward.
Where the checks mislead#
num_backends_by_application is only as precise as the names the clients set. Connections with no application_name fall into one group, and a revision that names its connections after the service instead of the revision merges both revisions into one line.
The minute samples can hide the moment the table was full. A pool that grows during a burst and shrinks again within the minute leaves the refusals in the application's logs and a total below the limit on the chart.
The old revision's idle instances can be shut down at any time, and the 15 minutes is an upper bound. Do not plan a rollout around them staying; plan the budget as if they stay the full 15 minutes.
For errors at a traffic step that are not about the database, such as instances that never started or requests aborted for lack of an instance, see errors after shifting traffic.
Questions#
Why do I get too many connections only during a Cloud Run gradual rollout?
Both revisions run instances during the split, and the old revision's instances can stay idle for up to 15 minutes while still holding their pools. The two revisions together can need more slots than either needs alone.
Does the service-level maximum instances setting limit both revisions during a split?
Yes. Cloud Run divides the service-level maximum among the revisions that receive traffic, in proportion to their share. Revision-level maximums apply to each revision separately, so with only those set, the service total can exceed any one of them.
How do I tell whether the new revision or the split caused too many connections?
Compare sessions per instance in each revision. If they are about equal and the sum filled the table, the overlap did it. If the new revision holds clearly more per instance, the release changed the connection count and will fail at full traffic too.