Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

cloud run cpu is in use after cpu allocation is done and even during allocation async function are v

I have a cloud run container that listen to pubsub topic,  with cpu throttling I have several questions regarding this behavior:

1. what is "request" that trigger cpu allocation ? 
2. i see that the container still run code after CPU allocation is over ( according to metrics and documentation ) , how can it be ? 
3. even during startup ( which the CPU is allocated) async/background operations are really slow, for example : check if topic exist in the pubsub takes 50 secoonds. why is that? 

really appreciate answers to those questions.  

0 2 1,562
2 REPLIES 2

Hi @dor-benatia ,

Welcome to the Google Cloud Community!

  1. By default, CPU allocation only occurs during the request processing, container startup and shutdown. During startup, the container instance listens for requests within 4 minutes after being started (See documentation here). Then it proceeds to process the request and shuts down. This is the Container Instance lifecycle
  2. Your allocation mode could be in CPU always allocated mode. This means that the CPU is always allocated and available even when there are no incoming requests. See documentation here.
  3. Container instances are scaled as needed, their startup time is affected by your service. It can also happen that your request is waiting for a new container instance to be processed. This process is called a Cold Start which explains the slow startup. See documentation here.

Let me know if it helped, thanks!

Hi @Marramirez and thank you for your response, regarding your suggested behavior explanation:
ive went through the documentation, my CPU is "allocated on request" and not "always allocated" and this is why i don't understand why it act like that.
regarding the cold start - i'm afraid this is not the case since i see the container up all the time ( with metrics). 

so i am still in the dark here .