CodexBloom - Programming Q&A Platform

GCP Cloud Run Service Timing Out Despite Sufficient Resources Configured

πŸ‘€ Views: 89 πŸ’¬ Answers: 1 πŸ“… Created: 2025-06-26
google-cloud-run timeout flask Python

I'm prototyping a solution and I need some guidance on I'm learning this framework and I'm stuck on something that should probably be simple... I'm working with an scenario with my Cloud Run service timing out after 60 seconds, even though I've configured it to allow up to 10 minutes. I’ve checked my service's settings and verified that the timeout is set correctly in the deployment. I'm using the Google Cloud SDK version `400.0.0` and deploying with the following command: ```bash gcloud run deploy my-service --image gcr.io/my-project/my-image --timeout 600 ``` However, when I send a request for a process that typically takes longer than a minute, I receive the following behavior message: ``` behavior: 504 Gateway Timeout ``` I've also verified that the service account has the necessary permissions and that the request is being routed correctly. Here’s the part of the code that handles the long-running process: ```python from flask import Flask, request import time app = Flask(__name__) @app.route('/long-process', methods=['POST']) def long_process(): time.sleep(70) # Simulating a long process return 'Process completed', 200 ``` Despite the timeout configuration, the request still fails after 60 seconds. I've tried testing it locally using `flask run` and it works without any issues. Can anyone guide to troubleshoot this timeout scenario? Is there anything I might be missing in the Cloud Run configuration or in the request handling process? I'm working on a service that needs to handle this. Any ideas what could be causing this? Thanks for your help in advance! I'm working on a service that needs to handle this. Am I approaching this the right way?