I have a cloud run container that listen to pubsub topic, with cpu throttling I have several questions regarding this behavior:
- what is “request” that trigger cpu allocation ?
- i see that the container still run code after CPU allocation is over ( according to metrics and documentation ) , how can it be ?
- 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.
Hi @dor-benatia ,
Welcome to the Google Cloud Community!
- 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.
- 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.
- 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!
1 Like
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 .