On this page

GCP Incident Scenarios

GCP-specific debugging playbooks — the same format as aws-scenarios.md but tuned for GKE, Cloud SQL, Pub/Sub, Cloud Run, Artifact Registry, and Spanner.

0/0 checks

1. GKE Node NotReady

Symptoms: kubectl get nodes shows a node in NotReady state; pods on that node are stuck in Terminating or Unknown.

flowchart TD
    A[kubectl get nodes → NotReady] --> B{Check node conditions}
    B -->|DiskPressure| C[/var/log full or containerd data dir full]
    B -->|MemoryPressure| D[OOM: system daemon or pod]
    B -->|PIDPressure| E["Too many processes / fork bomb"]
    B -->|No pressure flags| F{Is kubelet running?}
    F -->|No| G["systemctl start kubelet<br/>check journalctl -u kubelet"]
    F -->|Yes, but node still NotReady| H{Is containerd running?}
    H -->|No| I["systemctl start containerd<br/>df -h /var/lib/containerd"]
    H -->|Yes| J{OOM kill recently?}
    J -->|dmesg shows OOM| K["Increase node memory or<br/>limit offending workload"]
    J -->|No OOM| L["Node manually cordoned?<br/>check kubectl describe node"]
    L --> M[kubectl uncordon node-name]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,F,H,J,L check
    class C,D,E,G,I,K warn
    class M good
Step 1. Describe the node.

Run kubectl describe node <name> and scan the Conditions section for DiskPressure, MemoryPressure, or PIDPressure = True. Check Taints (a node may have been manually cordoned) and the Events block at the bottom for the most recent error.

Step 2. SSH into the node.

Use gcloud compute ssh <node-name> --zone <zone>. All further investigation happens on the node itself. GKE node names in the output of kubectl get nodes map directly to GCE instance names.

Step 3. Check kubelet.

Run systemctl status kubelet. If it's inactive (dead) or failed, read the logs: journalctl -u kubelet --since "10 minutes ago". Common causes: kubelet can't reach the API server, or a TLS cert has expired.

Step 4. Check containerd.

Run systemctl status containerd. If disk pressure is flagged, check: df -h /var/lib/containerd. GKE nodes accumulate image layers and log files in /var/log/pods/. A full disk stops containerd from pulling images or creating new containers.

Step 5. Check for OOM kills.

Run dmesg | grep -i 'out of memory'. If the kernel OOM killer fired, it logs the process name and PID. Also check: journalctl -k --since "30 minutes ago" for kernel ring buffer messages from before the node went NotReady.

Step 6. Remediate.

If the node is unhealthy and in a managed node pool, drain it and delete it — GKE will recreate it automatically:

kubectl drain <name> --ignore-daemonsets --delete-emptydir-data
kubectl delete node <name>

GKE auto-repair will provision a fresh node. If the pool has auto-repair disabled, enable it in the GCP Console or via gcloud container node-pools update.

Commands

# Cluster-side
kubectl get nodes
kubectl describe node <node-name>
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
kubectl delete node <node-name>

# On the node (gcloud compute ssh first)
systemctl status kubelet
journalctl -u kubelet --since "10 minutes ago"
systemctl status containerd
df -h /var/lib/containerd
df -h /var/log
dmesg | grep -i 'out of memory'
journalctl -k --since "30 minutes ago"

Common causes: disk pressure from log accumulation (/var/log/pods/ fills), containerd GC not running, Spot (preemptible) VM interrupted mid-workload, OOM kill from a system daemon (not a pod) that takes down kubelet with it.


2. Cloud SQL Connection Refused

Symptoms: App pods cannot connect to Cloud SQL; error is "connection refused", "dial tcp: connect: connection refused", or "SSL handshake timeout".

flowchart TD
    A[Connection refused to Cloud SQL] --> B{Is the instance RUNNABLE?}
    B -->|No: stopped or maintenance| C["gcloud sql instances describe<br/>wait for RUNNABLE state"]
    B -->|Yes| D{Auth Proxy pod running?}
    D -->|No / CrashLoopBackOff| E["Check proxy logs<br/>Verify SA has roles/cloudsql.client"]
    D -->|Yes| F{Private IP or Public IP?}
    F -->|Private IP| G{VPC peering to servicenetworking?}
    G -->|Peering missing| H["gcloud services vpc-peerings list<br/>Create peering or allocated IP range"]
    G -->|Peering OK| I{IAM permission on SA?}
    F -->|Public IP| I
    I -->|Missing| J["Add roles/cloudsql.client<br/>to the proxy service account"]
    I -->|Present| K{SSL required?}
    K -->|sslMode conflict| L["Check connection string sslMode<br/>gcloud sql ssl-certs list --instance"]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,D,F,G,I,K check
    class C,E,H,J,L warn
Step 1. Verify instance state.

Run gcloud sql instances describe <instance> and confirm state: RUNNABLE. If the instance is in a maintenance window or was manually stopped, it's unavailable. Check gcloud sql operations list --instance=<name> for in-progress operations.

Step 2. Check the Auth Proxy.

The Cloud SQL Auth Proxy is the standard connection method on GKE. Verify the pod is running: kubectl get pods -l app=cloud-sql-proxy. Read its logs: kubectl logs -l app=cloud-sql-proxy --tail=50. A "Permission denied" in proxy logs means the service account lacks roles/cloudsql.client.

Step 3. Verify IAM.

The Kubernetes service account (or its Workload Identity–mapped GCP service account) needs roles/cloudsql.client at the project level. Check:
gcloud projects get-iam-policy <project> --flatten="bindings[].members" --format='table(bindings.role,bindings.members)' | grep cloudsql

Step 4. Check VPC networking (Private IP).

If using private IP, Cloud SQL connects over VPC peering to the servicenetworking.googleapis.com network. Verify: gcloud services vpc-peerings list --network=<vpc-name>. If peering is missing or the allocated IP range is too small, private IP connections fail silently.

Step 5. Check SSL configuration.

Cloud SQL newer instances require SSL by default. Check your connection string for sslmode=disable (will fail) or sslmode=require. List client certs: gcloud sql ssl-certs list --instance=<name>. Client cert expiry (not server cert) causes SSL handshake failures.

Commands

gcloud sql instances describe <instance>
gcloud sql operations list --instance=<instance> --limit=5

kubectl get pods -l app=cloud-sql-proxy
kubectl logs -l app=cloud-sql-proxy --tail=50

gcloud projects get-iam-policy <project> \
  --flatten="bindings[].members" \
  --format='table(bindings.role,bindings.members)' | grep cloudsql

gcloud services vpc-peerings list --network=<vpc-name>

gcloud sql ssl-certs list --instance=<instance>

Common causes: Auth Proxy service account missing roles/cloudsql.client, private IP allocated range exhausted or VPC peering not created, SSL client cert expired (check expiry date in gcloud sql ssl-certs list), instance in scheduled maintenance window.


3. Pub/Sub Backlog Growing

Symptoms: subscription/num_undelivered_messages metric rising continuously; consumer pods appear healthy with no errors; backlog doesn't drain.

flowchart TD
    A["Pub/Sub backlog growing"] --> B{Consumer ACKing messages?}
    B -->|No ACK in logs| C["Consumer bug: processing but not calling Acknowledge<br/>Fix code to call msg.Ack after processing"]
    B -->|ACKing but slow| D{ackDeadlineSeconds vs processing time?}
    D -->|Deadline shorter than processing| E["Increase ackDeadlineSeconds to 600<br/>or call ModifyAckDeadline mid-processing"]
    D -->|Deadline OK| F{Dead letter topic configured?}
    F -->|DLQ filling up| G["Specific messages causing crashes<br/>Inspect DLQ: pubsub subscriptions pull dlq-sub"]
    F -->|No DLQ| H{Push or Pull subscription?}
    H -->|Push| I["Check push endpoint HTTP status<br/>non-2xx = Pub/Sub retries indefinitely"]
    H -->|Pull| J{Subscription filter too restrictive?}
    J -->|Yes| K["Messages published that don't match filter<br/>Are undelivered, not unprocessed"]
    J -->|No| L["Seek to now to reset backlog<br/>gcloud pubsub subscriptions seek --to-time=now"]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,D,F,H,J check
    class C,E,G,I,K warn
    class L good
Step 1. Inspect the subscription.

Run gcloud pubsub subscriptions describe <sub>. Check: ackDeadlineSeconds (default 10 — almost always too short for real processing), messageRetentionDuration (how long messages are kept), and whether a deadLetterPolicy is configured.

Step 2. Check the dead letter queue.

If deadLetterPolicy is set, messages that fail delivery N times are moved to the DLQ topic. Pull a few to see what's failing: gcloud pubsub subscriptions pull <dlq-sub> --limit 5 --auto-ack. A DLQ filling means specific messages are crashing the consumer.

Step 3. Check message age metric.

In Cloud Monitoring, look at pubsub.googleapis.com/subscription/oldest_unacked_message_age. If this grows linearly, the consumer is stuck on a specific message (it keeps receiving and nacking the same one). If it's flat but backlog grows, new messages arrive faster than they're consumed.

Step 4. Push vs pull verification.

For push subscriptions: Pub/Sub sends HTTP POST to your endpoint. Any non-2xx response is treated as a nack and retried with exponential backoff. Check your endpoint's error rate. For pull subscriptions: verify consumer code calls msg.Ack() or client.Acknowledge() after successful processing — not before.

Step 5. Reset the backlog if needed.

If the backlog is unprocessable (corrupted messages, all causing crashes), seek the subscription forward to discard the backlog. Warning: this permanently loses messages not retained elsewhere:

gcloud pubsub subscriptions seek <sub> --to-time=now

Better option: configure a dead letter topic first, let bad messages accumulate there, then inspect and replay good ones.

Commands

gcloud pubsub subscriptions describe <sub>

# Pull from DLQ subscription to inspect failing messages
gcloud pubsub subscriptions pull <dlq-sub> --limit 5 --auto-ack

# Seek to reset backlog (destructive — loses messages)
gcloud pubsub subscriptions seek <sub> --to-time=now

# Cloud Monitoring metrics to check
# pubsub.googleapis.com/subscription/num_undelivered_messages
# pubsub.googleapis.com/subscription/oldest_unacked_message_age

Common causes: consumer not calling ACK (processes message but forgets to acknowledge — message re-delivered after deadline), ackDeadlineSeconds too short for processing time (increase to 600), push endpoint returning 5xx (network issue, or the endpoint crashed), filter too narrow (messages published but none match the subscription filter).


4. Cloud Run 503 / All Instances Unavailable

Symptoms: All requests to a Cloud Run service return HTTP 503; container/instance_count is 0; requests not served at all.

flowchart TD
    A[Cloud Run 503 - All instances unavailable] --> B{Any instances starting?}
    B -->|instance_count stuck at 0| C{Check startup failure}
    C -->|Logs show exit code 137| D["OOM: increase memory limit<br/>gcloud run services update --memory"]
    C -->|Logs show exit code 1 or 2| E["App crash on startup<br/>Missing env vars, bad config, code bug"]
    C -->|No logs at all| F["Image pull failure<br/>Check Artifact Registry IAM: roles/artifactregistry.reader"]
    B -->|Instances starting but failing health check| G{Startup timeout?}
    G -->|App takes > 240s to start| H["Increase startup CPU boost<br/>or optimize startup path"]
    G -->|App starts fast| I{Scales to zero between requests?}
    I -->|Yes, cold start too slow| J["Set --min-instances 1<br/>to keep warm instance"]
    I -->|No| K["Max instances reached?<br/>Check --max-instances setting"]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,C,G,I check
    class D,E,F,H,J,K warn
Step 1. Inspect the revision.

Run gcloud run revisions describe <rev> --region <region>. Check the conditions block for Ready: False and the accompanying message. A stuck revision with ContainerFailed usually has a startup crash. Also check which revision is serving traffic: gcloud run services describe <service> --region <region>.

Step 2. Read the container logs.

Run gcloud run services logs read <service> --limit 50 --region <region>. Look for: exit codes (137 = OOM, 1/2 = app crash), error messages on startup, or complete absence of logs (image pull failure). Cloud Run logs are also in Cloud Logging under resource.type="cloud_run_revision".

Step 3. Check memory limits.

Exit code 137 means the container was sent SIGKILL, almost always OOM. Cloud Run enforces the memory limit strictly. Check current limit: gcloud run services describe <service> --format="value(spec.template.spec.containers[0].resources.limits.memory)". Increase it: gcloud run services update <service> --memory 1Gi --region <region>.

Step 4. Check cold start and min-instances.

Cloud Run scales to 0 when idle and takes a cold start on the next request. Cloud Run's startup timeout is 240 seconds by default. If your app takes > 30s to start (JVM warmup, model loading), consider --min-instances 1 to keep one warm instance, or enable CPU boost on startup.

Step 5. Check image pull access.

If there are no logs at all, the image likely can't be pulled. The Cloud Run service account needs roles/artifactregistry.reader on the registry: gcloud artifacts repositories get-iam-policy <repo> --location=<location>. On GKE-based services, also verify Workload Identity is configured.

Commands

gcloud run revisions describe <rev> --region <region>
gcloud run services describe <service> --region <region>
gcloud run services logs read <service> --limit 50 --region <region>

# Check memory config
gcloud run services describe <service> \
  --format="value(spec.template.spec.containers[0].resources)"

# Increase memory
gcloud run services update <service> --memory 1Gi --region <region>

# Set minimum instances to avoid cold starts
gcloud run services update <service> --min-instances 1 --region <region>

# Check Artifact Registry IAM
gcloud artifacts repositories get-iam-policy <repo> --location=<location>

Common causes: application startup taking > 240s (cold start limit), missing env vars causing app crash on startup (check for os.Getenv panics), memory limit too low for the workload, Artifact Registry auth failure when using a non-default service account.


5. Artifact Registry Auth Failure in CI

Symptoms: docker pull fails with "unauthorized: unauthenticated request"; gcloud builds submit works locally but GitHub Actions workflow fails.

flowchart TD
    A[Artifact Registry auth failure in CI] --> B{Workload Identity Pool configured?}
    B -->|No pool| C["Create WIF pool and GitHub OIDC provider<br/>gcloud iam workload-identity-pools create"]
    B -->|Pool exists| D{"SA has roles/artifactregistry.reader?"}
    D -->|Missing| E["gcloud artifacts repositories add-iam-policy-binding<br/>--member serviceAccount:SA --role roles/artifactregistry.reader"]
    D -->|Role present| F{GitHub Actions: id-token write permission?}
    F -->|Missing from workflow| G["Add permissions: id-token: write<br/>to the workflow job"]
    F -->|Present| H{Credential helper configured?}
    H -->|Not configured| I["gcloud auth configure-docker region-docker.pkg.dev<br/>or use docker/login-action with access token"]
    H -->|Configured| J{WIF attribute binding correct?}
    J -->|Repo name mismatch| K["Check attribute.repository == repo/name<br/>in WIF provider configuration"]
    J -->|OK| L["Test: gcloud auth print-access-token<br/>docker login with oauth2accesstoken"]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,D,F,H,J check
    class C,E,G,I,K warn
    class L good
Step 1. Verify the Workload Identity Pool.

Run gcloud iam workload-identity-pools list --location=global. The pool must exist with a GitHub OIDC provider configured. Check the provider: gcloud iam workload-identity-pools providers list --workload-identity-pool=<pool> --location=global. The provider's issuer URI must be https://token.actions.githubusercontent.com.

Step 2. Check the IAM binding.

The GCP service account needs roles/artifactregistry.reader (or writer for push) on the specific repository:

gcloud artifacts repositories get-iam-policy <repo> \
  --location=<location> \
  --format='table(bindings.role,bindings.members)'

Also check the WIF binding that allows GitHub to impersonate the SA.

Step 3. Configure the GitHub Actions workflow.

The workflow job must have id-token: write permission. Use google-github-actions/auth with the WIF provider and service account:

permissions:
  id-token: write
  contents: read
Step 4. Configure the Docker credential helper.

After google-github-actions/auth, configure Docker to use GCP credentials: gcloud auth configure-docker <region>-docker.pkg.dev. This adds the credential helper to ~/.docker/config.json so subsequent docker pull calls authenticate automatically.

Step 5. Test end-to-end.

Test the credential chain manually:

gcloud auth print-access-token | \
docker login -u oauth2accesstoken \
--password-stdin <region>-docker.pkg.dev

Then docker pull <region>-docker.pkg.dev/<project>/<repo>/<image>:tag. If this fails, the SA credential is the problem. If it succeeds but CI fails, the issue is WIF attribute binding (repo name mismatch in the OIDC token claim).

Commands

gcloud iam workload-identity-pools list --location=global
gcloud iam workload-identity-pools providers list \
  --workload-identity-pool=<pool> --location=global

gcloud artifacts repositories get-iam-policy <repo> --location=<location>

# Configure docker credential helper
gcloud auth configure-docker <region>-docker.pkg.dev

# Test access token
gcloud auth print-access-token | \
  docker login -u oauth2accesstoken --password-stdin <region>-docker.pkg.dev

# Add IAM binding if missing
gcloud artifacts repositories add-iam-policy-binding <repo> \
  --location=<location> \
  --member="serviceAccount:sa@project.iam.gserviceaccount.com" \
  --role="roles/artifactregistry.reader"

Common causes: WIF pool attribute binding uses wrong attribute (repo name in the condition doesn't match the actual GitHub repo path), id-token: write permission missing from workflow job permissions block, credential helper not configured (docker login not called after auth step), service account principal doesn't match the WIF binding condition.


6. GKE Ingress 502 Backend Unhealthy

Symptoms: GKE HTTP(S) Load Balancer returns 502; kubectl get ingress shows backends as unhealthy; pods show READY=1/1 but get no traffic.

flowchart TD
    A[GKE Ingress 502 - backends unhealthy] --> B{Check backend service health in GCP Console}
    B -->|All backends unhealthy| C{Firewall rules for health checks?}
    C -->|No rule for 130.211.0.0/22 or 35.191.0.0/16| D["Create firewall rule allowing TCP<br/>from health check source CIDRs"]
    C -->|Firewall OK| E{NEG endpoints populated?}
    E -->|NEG empty| F["Pod annotation issue<br/>check cloud.google.com/neg annotation on Service"]
    E -->|NEG has endpoints| G{Readiness probe matching?}
    G -->|Probe path mismatch| H["Align probe path with LB health check path<br/>typically /healthz or /ready"]
    G -->|Probe OK| I{Service port mapping?}
    I -->|Port mismatch| J["Ingress backend port.number must match<br/>Service.spec.ports port, not containerPort"]
    I -->|Port OK| K["Check pod logs for 4xx/5xx<br/>on health check requests"]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,C,E,G,I check
    class D,F,H,J,K warn
Step 1. Check backend health in GCP Console.

Navigate to Network services → Load balancing in GCP Console. Click on the load balancer, then the backend service. Each backend (NEG endpoint) shows its health status. Backends marked UNHEALTHY are failing health checks. Note the health check path — it's often / or /healthz.

Step 2. Check NEG endpoints.

Network Endpoint Groups map K8s pods to GCP load balancer backends. Verify NEGs exist and have endpoints:

gcloud compute network-endpoint-groups list
gcloud compute network-endpoint-groups list-network-endpoints <neg-name> \
  --zone <zone>

An empty NEG means pods aren't being registered — check the Service annotation cloud.google.com/neg: '{"ingress": true}'.

Step 3. Verify the firewall rule.

GCP health checks originate from two specific IP ranges: 130.211.0.0/22 and 35.191.0.0/16. A firewall rule allowing TCP on your pod's container port from these source ranges must exist:

gcloud compute firewall-rules list --format='table(name,sourceRanges,allowed)' \
  | grep -E "130.211|35.191"

If missing, create it: gcloud compute firewall-rules create allow-health-checks --allow tcp:<port> --source-ranges 130.211.0.0/22,35.191.0.0/16.

Step 4. Check the readiness probe.

The GKE Ingress health check is derived from the pod's readiness probe path. If the readiness probe returns 200 but the LB health check uses a different path, backends fail. Check: kubectl describe pod <pod> → Readiness probe path. Align the readiness probe path with what the LB is checking, or configure a custom health check path on the BackendConfig CRD.

Step 5. Verify Service port mapping.

The Ingress backend spec references a Service port number. This must match Service.spec.ports[].port (the service-level port), not containerPort. Check:

kubectl describe svc <service>
kubectl describe ingress <ingress>

If Ingress backend says port 80 but the Service exposes port 8080, traffic is routed nowhere and all backends appear unhealthy.

Commands

kubectl get ingress
kubectl describe ingress <ingress>
kubectl describe svc <service>
kubectl describe pod <pod>

# NEG inspection
gcloud compute network-endpoint-groups list
gcloud compute network-endpoint-groups list-network-endpoints <neg> --zone <zone>

# Firewall check
gcloud compute firewall-rules list \
  --format='table(name,sourceRanges,allowed)'

# Create health check firewall rule if missing
gcloud compute firewall-rules create allow-health-checks \
  --allow tcp:<container-port> \
  --source-ranges 130.211.0.0/22,35.191.0.0/16 \
  --network <vpc-name>

Common causes: missing firewall rule for health check source IPs (most common — no rule → all health checks fail → all backends unhealthy), readiness probe path doesn't match the LB health check path, NEG not being updated when pods are replaced (missing annotation on Service), Service port number mismatch in Ingress spec.


7. Cloud Spanner High Latency

Symptoms: spanner.googleapis.com/api/request_latencies p99 growing; user-facing API slowing; Cloud Monitoring shows Spanner CPU > 65%; no obvious traffic spike.

flowchart TD
    A[Spanner high latency] --> B{"CPU utilization > 65%?"}
    B -->|Yes| C{Writes concentrated on one split?}
    C -->|Monotonic primary key| D["Hot key / write hotspot<br/>Switch to UUID or hash-prefixed keys"]
    C -->|Distributed writes| E["Under-provisioned: add nodes<br/>gcloud spanner instances update --nodes"]
    B -->|No| F{Slow query detected?}
    F -->|Yes, full table scan| G["Missing index<br/>CREATE INDEX on filtered column"]
    F -->|Parameterized queries OK| H{Multi-region? Replication lag?}
    H -->|Leader not in user's region| I["Route writes to leader region<br/>or use PDML for batch updates"]
    H -->|Single region| J{Large transactions?}
    J -->|> 20k mutations per commit| K["Split into smaller commits<br/>or use PDML for bulk changes"]

    classDef bad fill:#ff6b6b,stroke:#c0392b,color:#fff
    classDef warn fill:#f39c12,stroke:#d68910,color:#fff
    classDef good fill:#27ae60,stroke:#1e8449,color:#fff
    classDef check fill:#3498db,stroke:#2980b9,color:#fff

    class A bad
    class B,C,F,H,J check
    class D,E,G,I,K warn
Step 1. Check CPU utilization.

In Cloud Monitoring, look at spanner/instance/cpu/utilization_by_priority. If CPU is > 65%, Spanner begins throttling requests. At > 90%, latency degrades severely. CPU is split by priority (high/low) — high-priority (user-facing) above 65% is the problem. Options: add processing nodes or fix the hot key causing the load.

Step 2. Identify hot keys.

Look at spanner/instance/cpu/utilization_by_operation broken down by database_id. If writes are concentrated on one node (one key range), a monotonic primary key is the cause. INT64 auto-increment or timestamp PKs route all new rows to the same split — the rest of the cluster is idle while one node is maxed out.

Step 3. Analyze slow queries.

Use Spanner Query Insights in the GCP Console (Spanner → your database → Query insights). Sort by total latency. Look for: full table scans (no index used), large result sets, missing WHERE clause filters. Also run EXPLAIN directly:

gcloud spanner databases execute-sql <db> \
  --instance=<instance> \
  --sql="EXPLAIN SELECT * FROM orders WHERE user_id = @uid"
Step 4. Add indexes or fix the primary key.

Add a secondary index for missing filters — zero-downtime, Spanner builds it in the background:

CREATE INDEX orders_by_user ON orders(user_id);

For hot key: change the primary key to a UUID (GENERATE_UUID()) or bit-reverse the existing integer key. This distributes new rows evenly across all Spanner splits.

Step 5. Scale the instance if needed.

If writes are evenly distributed but CPU is still high, the instance is under-provisioned. Add processing nodes:

gcloud spanner instances update <instance> --nodes=3

Spanner auto-rebalances splits across the new nodes within minutes. For variable load, use Spanner Autoscaler (OSS) or configure autoscaling on the instance directly (GA in newer regions).

Commands

# Cloud Monitoring metrics (query in Console or via API)
# spanner/instance/cpu/utilization_by_priority
# spanner/instance/cpu/utilization_by_operation
# spanner/api/request_latencies (filtered by method)

# Query analysis
gcloud spanner databases execute-sql <db> \
  --instance=<instance> \
  --sql="EXPLAIN SELECT * FROM orders WHERE status = 'pending'"

# Add index
gcloud spanner databases ddl update <db> \
  --instance=<instance> \
  --ddl="CREATE INDEX orders_by_status ON orders(status);"

# Scale instance
gcloud spanner instances update <instance> --nodes=3

# Describe instance
gcloud spanner instances describe <instance>

Common causes: monotonic primary keys (timestamps or auto-increment integers as PK cause all new-row writes to route to the same Spanner split), full table scans from missing indexes, instance CPU > 65% with no autoscaling configured (Spanner does not auto-scale by default — requires manual node addition or Spanner Autoscaler), large transactions exceeding 20,000 mutations per commit.


Your GKE Ingress shows all backends as UNHEALTHY even though every pod shows READY=true and passes its readiness probe. What is the most likely cause?

A Pub/Sub subscription accumulated 10 million messages over 3 days because consumer code crashed on one malformed message. You've deployed a fix. What should you verify before declaring the incident resolved?

Cloud Spanner p99 latency is spiking and CPU utilization is at 80%. You inspect the schema and find the primary key is user_id INT64 NOT NULL DEFAULT (FARM_FINGERPRINT(GENERATE_UUID())). Is this a hot key problem?

Edit this page on GitHub ↗