0

In an related but different question I was given a reference to Lifetime of a cloud run The idle state sounds great for my needs, how would an app typically enter the idle state, just calling sleep and wait for an incoming http request, or does it need to call some API functions in the Cloud Run to voluntarily give up its CPU time?

Some background about the project probably not relevant for the question:

The app will handle work in bursts typicality 5-20 minutes of work every other hour. Currently the work is revived on a pubsub, when possible several items of work are combined into one unit and then recites of completed work is submitted on another pubsub. So the app itself is aware of when it is working hard and when it is idle, hence this section caught my attention. I could potentiality redesign the flow to use http if that will make the lifetime easier.

Simson
  • 3,373
  • 2
  • 24
  • 38
  • Can you provide more details what are you trying to achieve? If the instance is dispatching some requests, then it cant be downscaled/terminated. If it does not process any requests, then it cant "give up its CPU time" as it doesnt do anything already, no? – yedpodtrzitko Jun 16 '23 at 01:11
  • I could describe my entire app but I think that would be distraction and not the stack-overflow minimal example. I will add a section above. – Simson Jun 16 '23 at 02:28
  • `Cloud run` instances become idle, if they are not receiving any requests. You don't need to do anything. When a Cloud Run container is idle, its CPU is throttled to nearly zero. This means that your application will run at a very slow pace, but you won't be charged for the CPU time. – Roopa M Jun 16 '23 at 04:35
  • @RoopaM Thanks write that as an answer and I will accept it. – Simson Jun 16 '23 at 05:50
  • 1
    I turned my comment into answer, have a look at it. – Roopa M Jun 16 '23 at 06:28

1 Answers1

1

Cloud run instances become idle, if they are not receiving any requests. You don't need to do anything. When a Cloud Run container is idle, its CPU is throttled to nearly zero. This means that your application will run at a very slow pace, but you won't be charged for the CPU time.

Reference

Simson
  • 3,373
  • 2
  • 24
  • 38
Roopa M
  • 2,171
  • 4
  • 12