简体   繁体   中英

Cloud run with CPU always allocated is cheaper than only allocated during request processing. How?

I use Cloud Run for my apps and trying to predict the costs using the GCP pricing calculator. I can't find out why it's cheaper with CPU always allocated instead of CPU allocated during request processing when it says "When you opt in to "CPU always allocated", you are billed for the entire lifetime of container instances".

Any explanation?

Thank you!

Cloud Run is serverless by default: you pay as you use. When a request comes in, an instance is created (and started, it's called cold-start) and your request processed. The timer starts. When your web server send the answer, the timer stop.

You pay for the memory and the CPU used during the request processing, rounded to the upper 100ms. The instance continue to live for about 15 minutes (by default, can be changed at any moment) to be ready to process another request without the need to start another one (and wait the cold start again).

As you can see, the instance continue to live EVEN IF YOU NO LONGER PAY FOR IT. Because you pay only when a request is processed.


When you set the CPU always on, you pay full time the instance run. No matter the request handling or not. Google don't have to pay for instances running and not used, waiting a request as the pay per use model. You pay for that, and you pay less

It's like a Compute Engine up full time. And as a Compute Engine, you can have something similar to sustained used discount . That's why it's cheaper.

In general it depends on how you use cloud run. Google is giving some hints here: https://cloud.google.com/run/docs/configuring/cpu-allocation

To give a summary to the biggest pricing differences:

CPU is only allocated during request processing

you pay for:

  • every request on a per request basis
  • cpu and memory allocation time during request
CPU always allocated

you pay for

  • cpu and memory allocation with a cheaper rate for time of instance active

Compare the pricing here: https://cloud.google.com/run/pricing

So if you have a lot of request which do not use a lot of ressources and not so much variance in it, then "always allocated" might be a lot cheaper.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM