nabulaer
nabulaer

Reputation: 351

cloud run is closing the container even if my script is still running

I want to run a long-running job on cloud run. this task may execute more than 30 minutes and it mostly sends out API requests. cloud run stops executing after about 20 minutes and from the metrics, it looks like it did not identify that my task is still in the running state. so it probably thinks it is in idling and closing the container. I guess I can run calls to the server while job run to keep the container alive, but is there a way to signal from to container to cloud run that job is still active and not to close the container?

I can tell it is closing the container since the logs just stop. and then, the next call I make to the cloud run endpoint, I can see the "listening" log again from the NodeJS express.

Upvotes: 5

Views: 4711

Answers (5)

bloukanov
bloukanov

Reputation: 77

I was having this issue with my cloud run service. It looks like setting the "min instances" to at least 1 solves it

Upvotes: 0

Sumit Katre
Sumit Katre

Reputation: 1

Other option you can increase request timeout of container to 1 hour from 5 min, if your backend request gets complete in 1 hour

Upvotes: -2

Hitesh Kumar
Hitesh Kumar

Reputation: 11

Yes, You can use.You can create an timer that call your own api after 5 minutes, so no timeout after 15 minutes.Whenever timer executes it will create a dummy request on your server.

Upvotes: -2

ahmet alp balkan
ahmet alp balkan

Reputation: 45196

I want to run a long-running job on cloud run.

This is a red herring.

On Cloud Run, there’s no guarantee that the same container will be used. It’s a best effort.

While you don’t process requests, your CPU will be throttled to nearly 0, so what you’re trying to do right now (running a background task and trying to keep container alive by sending it requests) is not a great idea. Most likely your app model is not fit a for Cloud Run, I recommend other compute products that would let you run long-running processes as well.

Upvotes: 9

Doug Stevenson
Doug Stevenson

Reputation: 317302

According to the documentation, Cloud Run will time out after 15 minutes, and that limit can't be increased. Therefore, Cloud Run is not a very good solution for long running tasks. If you have work that needs to run for a long amount of time, consider delegating the work to Compute Engine or some other product that doesn't have time limits.

Upvotes: 7

Related Questions