0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Google Cloudの Cloud Runで Worker Timeout

Last updated at Posted at 2025-11-27

Google Cloudの cloud runでPythonのFlaskを使ったときの困ったことのメモ。

デプロイはできたけど、すぐWorkerがTimeoutを起こしてしまう問題

通常のgcloudコマンドでのデプロイでは、起動時のTimeoutが30秒で発生してしまう。
CPUやメモリを増やしても改善しない。

そういうときは、Gunicornのタイムアウトを調整すればOK

gcloud run deploy ●●● \
  --project ●●● \
  --set-env-vars TZ=Asia/Tokyo,GUNICORN_CMD_ARGS="--timeout 610" \
  --region=us-central1 \
  --source=. \
  --timeout 600 \
  --max-instances 1 \
  --concurrency 1 

こんな感じで環境変数をデプロイすればOK

さらにCPUやメモリを増やしたいときは

  gcloud run services update ●●● \
    --region=us-central1 \
    --project=●●● \
    --memory 4Gi \
    --cpu 8

でアップデートするとより重い処理を完了しやすくなる

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?