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.
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.