504 cloud runtime_error ai_generated partial

HTTP 504 Deadline Exceeded: upstream request timeout after 60s while waiting for Cloud Run container to start

ID: cloud/gcp-cloud-run-cold-start-http-timeout

Also available as: JSON · Markdown · 中文
82%Fix Rate
85%Confidence
1Evidence
2023-09-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Cloud Run managed platform (gcloud CLI 450.0.0) active — — —
Cloud Run for Anthos 1.28 active — — —
Google Cloud SDK 450.0.0 active — — —

Root Cause

Cloud Run cold start latency exceeded the 60-second HTTP load balancer timeout because the container image is large or the application initialization is slow.

generic

中文

Cloud Run 冷启动延迟超过了 60 秒的 HTTP 负载均衡器超时,原因是容器镜像过大或应用程序初始化缓慢。

Official Documentation

https://cloud.google.com/run/docs/troubleshooting#504-deadline-exceeded

Workarounds

  1. 75% success Reduce container image size by using a slim base image (e.g., 'alpine' instead of 'ubuntu') and removing build dependencies. For Node.js apps, run 'npm prune --production' before building the image.
    Reduce container image size by using a slim base image (e.g., 'alpine' instead of 'ubuntu') and removing build dependencies. For Node.js apps, run 'npm prune --production' before building the image.
  2. 95% success Enable min-instances for Cloud Run to keep at least one instance warm: 'gcloud run services update SERVICE --min-instances=1'. This eliminates cold starts for most requests.
    Enable min-instances for Cloud Run to keep at least one instance warm: 'gcloud run services update SERVICE --min-instances=1'. This eliminates cold starts for most requests.

中文步骤

  1. Reduce container image size by using a slim base image (e.g., 'alpine' instead of 'ubuntu') and removing build dependencies. For Node.js apps, run 'npm prune --production' before building the image.
  2. Enable min-instances for Cloud Run to keep at least one instance warm: 'gcloud run services update SERVICE --min-instances=1'. This eliminates cold starts for most requests.

Dead Ends

Common approaches that don't work:

  1. 95% fail

    Larger resources do not reduce cold start time; they only affect runtime performance. Cold start is dominated by image download and app startup.

  2. 80% fail

    Startup CPU boost only helps during the startup probe period, not the initial HTTP request timeout. The 504 occurs before the probe even begins.