iTranslated by AI
Saving Google Cloud Costs with Committed Use Discounts: A Case Study
Committed Use Discounts (CUDs) are discounts applied by committing to use a certain amount of resources for a fixed period. In this article, I'd like to share my experience purchasing Committed Use Discounts for Cloud Run and Cloud SQL, which we use here at Zenn.
What are Committed Use Discounts?
To recap, a Committed Use Discount is a discount applied by committing to use a certain amount of resources for a fixed period. The duration and discount rate depend on the service. For example, in the case of Cloud Run, you can receive a 17% discount by committing to pay for a fixed cost for one or three years.
There are two types of commitments: one where you commit to a "cost" per unit of time, and another where you commit to "resources." A cost-based commitment is a contract to pay a fixed amount for a set period. A resource-based commitment is a contract to use specific resources like vCPUs or memory (this is an option exclusive to Compute Engine).
Since there are various restrictions depending on the service, please refer to the official documentation for details.
How to Determine Commitment Amounts
The following discussion is entirely about "cost-based commitments."
Because a commitment sets a cost per hour, the method for determining the commitment amount depends on whether the cost is fixed or variable. As a typical example, for services like Cloud SQL where instances are constantly running, the hourly cost is fixed. Conversely, for services like Cloud Run, where you use only the resources you need when you need them, the hourly cost fluctuates, so this factor must be taken into account.
Below, I will describe the specific example at Zenn.
Cloud SQL
First, let's check the current costs. The following is a graph of the cost of Cloud SQL in Zenn's production environment for a single day. You can see that the hourly cost remains constant.

Cloud SQL costs for a single day before applying CUDs
Next, I'll investigate the costs eligible for the Committed Use Discount. Since Cloud SQL's CUDs cover vCPU and memory, I checked the hourly prices for vCPU and memory in the Tokyo region from the pricing page.

Pricing at the time of writing
Although the prices after applying the CUD are also displayed, you should specify the on-demand prices for the commitment.
Zenn's production Cloud SQL runs on an HA configuration with 2 vCPUs and 7.5 GB of memory.
Converting this to cost:
- HA vCPU is 2, so
$0.1074 * 2 = $0.2148 - HA memory is 7.5, so
$0.0182/GB * 7.5 = $0.1365
This totals $0.3513.
Since the commitment is made in $0.01 increments, we round down to $0.35.
I entered this commitment amount into the Committed Use Discount purchase page to complete the purchase.

Committed Use Discount purchase page
This means that I can purchase $0.35 worth of hourly usage for $0.168.
The graph after application is as follows:

Cloud SQL costs for a single day after applying CUDs
It is covered perfectly by the commitment, isn't it? 🤗
A 52% discount was applied to the previous cost of $252/mo, resulting in a saving of $132/mo 🎉
Cloud Run
Below is a graph of the cost of Cloud Run in Zenn's production environment for a single day. In contrast to Cloud SQL, you can see that there are fluctuations in the charges. On this day, the cost fluctuated by about two times at its peak.

Cloud Run costs for a single day before applying CUDs
Incidentally, the time zone of the graph is UTC-8, so 0:00 on the graph is 5:00 PM of the previous day. Since Cloud Run scales significantly during sudden bursts, it seems the cost does not simply scale proportionally to the number of requests.
When deciding on a commitment, I felt it was necessary to look at it from a slightly more long-term perspective. At Zenn, we set the commitment to 80% of the average hourly cost of the month with the lowest cost among the past three months.
Additionally, while the total cost of Cloud Run includes network usage that is not eligible for Committed Use Discounts, I checked the breakdown of costs and found that it was only a negligible percentage, so I decided to ignore it.
With that, the derived commitment was $0.52. I entered this amount into the Committed Use Discount purchase page and made the purchase.

Committed Use Discount purchase page
This means that I can purchase $0.52 worth of hourly usage for $0.4316.
The graph after application is as follows:

Cloud Run costs for a single day after applying CUDs
For a calculation formula decided roughly, it turned out pretty well 🤗
The previous cost (the amount used as the basis for the calculation) was $470/mo. Applying an 80% coverage range and ignoring the small amount that could not be fully utilized, a simple calculation gives $470 * 0.80 * 0.17 = $63.92, resulting in savings of approximately $64 🎉
Thoughts
Finally, I would like to conclude by writing about what was good about using Committed Use Discounts and some points of caution.
The Good Points of Committed Use Discounts
- It is not a lump-sum prepayment, but a contract to pay a fixed amount every month. Since it simply discounts the costs that were already being paid on-demand every month, the hurdle for obtaining internal approval was low.
- Depending on the service, the discount rate is quite high. For example, Cloud SQL can be discounted by up to 52%. Since major changes like switching away from Cloud SQL are unlikely, I think it is worth betting on at this discount rate.
- Cost-based commitments are applied even if the type of resources you use changes. For example, for Cloud SQL, even if you change from a single instance configuration to an HA configuration, or from MySQL to PostgreSQL, it is not a problem because you are committing to the "cost."
Points of Caution for Committed Use Discounts
- Naturally, you cannot cancel a purchase. Make sure to purchase them when there is a prospect of long-term usage.
- It is a contract for hourly costs. As I wrote in this article, services like Cloud Run have large fluctuations in hourly costs, so you need to take those fluctuations into account when deciding on your commitment.
Aside
When I checked the cost report the day after purchasing the Committed Use Discounts, the coverage for Cloud SQL was 0%, so I panicked thinking I had messed up the settings and wasted the company's money. It seems like Cloud SQL has a longer report update interval.

Cloud Run report the day after purchase

Cloud SQL report the day after purchase
Discussion