cloud
performance
ai_generated
true
Cloud Run request takes 30s+ on first invocation due to large container image
ID: cloud/gcp-cloud-run-cold-start-large-image
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Cloud Run pulls the container image on cold start. Images >1GB can take 10-30s+ to pull. Google's docs recommend small images but don't quantify the cold start penalty per image size.
genericWorkarounds
-
92% success Use multi-stage Docker builds to minimize image size
FROM golang:1.21 AS builder ... FROM gcr.io/distroless/static ... COPY --from=builder /app /app
-
90% success Set min-instances > 0 AND set CPU to 'always allocated' for consistent performance
gcloud run deploy --min-instances=2 --cpu-boost --no-cpu-throttling
-
85% success Use startup CPU boost to reduce cold start latency
gcloud run deploy --cpu-boost # doubles CPU during startup for faster init
Dead Ends
Common approaches that don't work:
-
Set min-instances=1 and assume zero cold starts
78% fail
min-instances keeps 1 instance warm, but concurrent request spikes still trigger cold starts for additional instances.
-
Use a health check endpoint to keep instances warm
82% fail
Cloud Run auto-scales to zero regardless of health checks. There's no built-in keep-alive mechanism.