Adrian
Adrian

Reputation: 2113

Cloud Function CPUMilliSeconds quota exceeded

I've noticed a substantial number in my golang Cloud Function errors:

Error: quota exceeded (Quota exceeded for quota group 'CPUMilliSeconds' and limit 'CPU allocation in function invocations for us-central1 per 100 seconds' of service

What strange, is that I have no more than 60 invocations per second with 30 active instances cloud function running at the peak.

I understand that is that you can have a max of 1,000 concurrent instances, which in my case 30 is far cry to hit CPU limit.

Cloud function quota here

What is the best way to control Cloud Function CPU execution ?

Would you recommend using CloudRun instead of Cloud Functions for some more CPU "demanding task"?

Upvotes: 0

Views: 977

Answers (1)

Happy-Monad
Happy-Monad

Reputation: 2002

One of the quota limits of Google Cloud Functions is GHz-seconds which means the total amount of CPU seconds consumed by all running functions, the error you see is raised when you're reach that quota during a 100s time frame. Since your function is carrying a computationally intensive workload it's easier to reach the limit.

As for how to control CPU usage the only way would be to delay your requests to keep your usage below these limits. The alternative would be giving less memory to the function which in turn will be counterproductive because your functions will span longer time and you might run in the same trouble anyway.

As Doug pointed out Cloud Functions are not intended for your use case and neither Cloud Run. GCE instances are better for computationally intensive operations as there are no memory limitations but the amount you have provided, they also allow to run containerized code in an Container Optimized OS.

Hope this helps.

Upvotes: 3

Related Questions