The Silent Budget Killer
Cloud bills creep up. You start with a small instance, a managed database, and a bucket. A year later, you're paying for resources you forgot existed. The worst part? Most of that waste is avoidable with a few simple habits.
I've been there. After a particularly painful invoice, I made a checklist of practices that now keep my cloud spending in check. Here's what works.
1. Tag Everything from Day One
Tags are not just for organization; they are your cost allocation superpower. Without tags, you can't answer the question: "What is this cost for?"
Start tagging every resource with at least project, owner, and environment (dev, staging, prod). Most cloud providers let you enforce tags with policies. For example, in AWS, you can use a service control policy to deny creation of untagged resources.
# Example: tagging an EC2 instance with AWS CLI
aws ec2 create-tags --resources i-1234567890abcdef0 --tags Key=project,Value=myapp Key=owner,Value=team-x
Once tags are in place, use the provider's cost explorer to group by tags. You'll immediately spot the expensive experiment that no one turned off.
2. Turn Off What You're Not Using
This sounds obvious, but it's the most common leak. Developers spin up a server for testing and forget it. That server runs 24/7, costing money even when idle.
Get into the habit of stopping (not terminating) instances when you're done. Even better, automate it. Use a simple script that stops instances outside business hours.
# Example: using boto3 to stop instances with a tag 'auto-stop'
import boto3
from datetime import datetime
ec2 = boto3.resource('ec2')
now = datetime.now().hour
if now >= 19 or now < 7: # outside 7am-7pm
instances = ec2.instances.filter(Filters=[{'Name': 'tag:auto-stop', 'Values': ['true']}])
for i in instances:
if i.state['Name'] == 'running':
i.stop()
For databases, consider stopping them too if your provider supports it (e.g., RDS can be stopped). For dev environments, use a schedule to start them in the morning and stop at night.
3. Right-Size Your Resources
We tend to over-provision. A t3.medium might be more than enough, but you chose t3.large because you weren't sure. That doubles the cost.
Review your usage metrics regularly. Cloud providers give you CPU, memory, and network stats. If utilization is consistently below 20% for a week, downsize. It's a quick change, and you can always scale back up if needed.
# Example: modify an EC2 instance type
aws ec2 modify-instance-attribute --instance-id i-123 --instance-type '{"Value": "t3.medium"}'
For managed services like databases, look at your storage and IOPS. Often you're paying for provisioned IOPS you never use.
4. Use Serverless and Managed Services When It Makes Sense
If you have a service that gets sporadic traffic, a serverless function (like Lambda) can be dramatically cheaper than a dedicated server. You pay per request and compute time, not for idle capacity.
Similarly, managed services like Fargate for containers or Cloud Run for containers remove the need to manage servers. They scale to zero, so you pay nothing when there's no traffic.
But be careful: serverless isn't always cheaper. If you have steady, predictable load, a reserved instance might be better. The key is to match the service to your traffic pattern.
5. Set Budgets and Alerts
You can't manage what you don't measure. Set a monthly budget for each project or environment. Most cloud providers have native budget tools that alert you when you're approaching the limit.
For example, in AWS, you can create a budget with a threshold of 80% and 100%. You'll get an email when you hit those. Do the same for your other providers.
# Example: create a budget in AWS
aws budgets create-budget --account-id 123456789012 --budget file://budget.json
Make it a habit to check your cost dashboard every Monday. Ten minutes can save you hundreds.
6. Clean Up Orphaned Resources
When you delete an instance, its volumes might remain. Elastic IPs that aren't attached cost money. Snapshots pile up. These are the "zombie" resources that haunt your bill.
Every month, go through your console and look for:
- Unattached volumes
- Unattached elastic IPs
- Old snapshots
- Load balancers with no instances
Delete them. If you're using infrastructure as code, you can automate this with a script that lists and deletes orphaned resources, but be careful not to delete something in use.
7. Choose the Right Pricing Model
For predictable workloads, reserved instances or savings plans can cut costs by up to 60%. You pay upfront or commit to a term, and you get a significant discount.
If you have flexible workloads, spot instances can be up to 90% cheaper, but they can be interrupted. Use them for batch jobs or stateless workers.
Don't just pay on-demand out of habit. Review your usage patterns and commit where it makes sense.
The Habit Loop
None of these are one-time fixes. They are habits. Tag as you go. Stop when done. Review monthly. The payoff is a predictable bill and money back in your pocket.
Start with one habit today. Your future self will thank you.
Top comments (0)