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

Is there no way to deploy cloud functions 2nd gen with unthrottled cpu?

I got an error when deploying after change cpu setting of cloud run(with cloud functions 2nd gen) to unthrottled, 

 
ERROR: (gcloud.beta.functions.deploy) INVALID_ARGUMENT: Could not update Cloud Run service ******. spec.template.spec.containers[0].resources.limits.cpu: Invalid value specified for cpu with cpu unthrottled. Must be equal to one of 1.0, 2.0, 4.0, 6.0, 8.0
 
I did resolve the error by change cpu setting to throttled. But I want to use cloud functions 2nd gen with cpu unthrottled. How can I do it?
0 3 2,685
3 REPLIES 3

Since Cloud Functions Gen 2 are powered by Cloud Run, they appear as Cloud Run services. For a Cloud Run service to have always on CPU (unthrottled), it needs to have allocated at least 1 CPU and 512MiB of memory.

I tested deploying a Gen 2 function and by default it had allocated less than the required resources for unthrottled CPU. I then updated the function with enough resources to enable it:

gcloud beta run services update <FUNCTION_NAME> --region <REGION> --cpu 1 --memory=512Mi --no-cpu-throttling

Here is the command reference for the full set of flags.

Thank you for reply.

The reason I asked was I got the error when redeploying cloud functions after update cpu unthrottled option on cloud run service.
I already know how to change cpu option after deploy once. 😞

Can you explain more about the use case of your function? Do you need unthrottled CPU usage for a specific resource intensive task? In that case, a GCE instance could be more appropriate for you. 

Otherwise, you can submit a feature request to incorporate these command options to Cloud Functions Gen 2, which is worth mentioning are in preview phase, and might not be feature-complete as of this time.

Top Solution Authors