Have you set a budget for your cloud project yet? It saved us $40 a day

David Dikman
Nerd For Tech
Published in
5 min readNov 9, 2022

Maintaining a server yourself is a lot of work. Cloud services usually outperform cost and effort-wise unless you have poor luck and no safety controls in place.

The cost of a cloud project I worked on recently, suddenly and without warning, increased by $40 a day. Thankfully, we had a budget in place, got alerted and could fix the problem right away.

Add a budget now

If you do not have a budget set for your project already, stop reading now and go add it. I’ll wait.

All done? Good job!

It still surprises me that setting a budget is not an obligatory step when creating a new cloud project. The costs can spiral so quickly, and I don’t think anyone benefits if they do (I am sure unintentional usage and costs hurt the cloud providers too).

As an example, I know one project that had a breach of credentials. The attacker used the account for something (perhaps mining crypto or scraping) and the costs went through the roof.

Budget what it should cost

A budget is usually how much money you can spend. But when we set a budget for cloud projects, it should be set as an alert for how much we need to spend.

We shouldn’t use that money if we don’t have to; any time we can, we should try to reduce it.

The easiest way to set your budget is to look at a day’s worth of running your infrastructure. Multiply that by the number of days in a month. This is what you need to budget for your system to continue running.

Chances are, you quickly realize you can’t afford that, and you can probably optimize some parts to cost less. If you can afford it and it is no surprise to you, your team has done a great job!

If this budget is ever exceeded, you will want to know right away. Because if it does, you might be operating at a loss. The sooner you can react, if not for your own sake, your employer will surely appreciate it.

Configure an alert for your budget

The budget only helps if you are notified as soon as you risk going over the budget.

The $40 increase in this project I worked on, was raised to me thanks to an alert set up to trigger when the expected monthly cost exceeded 110% of the previous month’s budget.

This setup allows for a slow increase in budget from month to month, expected with an increase in users and usage. However, if the increase is ever too step, you will be alerted right away.

Example of an alert set up in Google Cloud (the amounts are intentionally masked)

Google Cloud Platform allows advanced billing notifications over Pub/Sub as well as email notifications. Using that you can code your own notifications or triggers, but, in my experience, a simple email is good enough. Together with the Slack email app, these email notifications can be raised in slack as well.

Example of a billing alert email forwarded to slack using the Slack email app and Gmail

What could cause a spike in costs?

The worst cost spike, as in the example above, is from illegal or malicious use. Such as if someone is scraping your content or performing a denial of service (DOS) attack.

But there are far more common and less obvious reasons for spikes. In my most recent experience, due to usage and price changes.

Price increase due to usage

Though this is the least worrisome spike, as it means people are using your product, it is a cost that must be managed.

I use the Firebase free tier for any of my projects. It is excellent but quickly runs out, and you end up paying.

The below graph shows the cost of BigQuery, which suddenly starts in the middle of the month once the free tier has been used up.

An example of how BigQuery costs start piling up after the free tier is used up

Increase due to price changes

Although hopefully, you will be notified in due time and can prepare, it is very easy to miss changes in pricing. Even if you are informed, it is hard to know if and how it might affect you.

I wrote this post due to a price change. I have still not been able to find any notice of this price change, but from October 1st, the GCP Uptime checks pricing changed.

This caused our project to cost an additional $40 a day once the free tier was used.

From the stack driver pricing page

Carefully monitoring price updates from your cloud provider can help avoid surprises, but something will eventually slip through. When they do, you will want to have a budget set so you can catch it quickly and react.

Never go without a budget

I hope this post helped highlight why having a budget is important. It takes just a few minutes to set up and can save a lot of money.

Thank you for reading. I hope it was helpful. I will add some extra posts later on how to reduce costs and troubleshoot spikes when they occur.

Feel free to reach out if you have any questions.

--

--

David Dikman
Nerd For Tech

Full-stack developer and founder. Writing here and at https://greycastle.se. Currently open for contract work.