DEV Community

Cloud Frontier
Cloud Frontier

Posted on

Cutting Cloud Costs with a Few Habits

The Silent Budget Killer

Cloud bills sneak up on you. One month you're paying $50, the next it's $500. The worst part? Most of that money goes to resources you forgot existed. I've been there, and I've learned that fixing cloud costs isn't about a big migration or buying reserved instances. It's about building a few simple habits that compound over time.

Habit 1: Tag Everything from Day One

Tags are the foundation of cost visibility. If you can't attribute a cost to a project, team, or environment, you can't make decisions about it. Start tagging every resource when you create it. Use a consistent scheme like project, owner, and environment (dev, staging, prod).

# Example: tagging an EC2 instance in AWS
aws ec2 create-tags --resources i-1234567890abcdef0 --tags Key=project,Value=checkout-service Key=owner,Value=payments-team Key=environment,Value=prod
Enter fullscreen mode Exit fullscreen mode

If you have untagged resources, write a script to find them and add a unknown tag. Then review that list monthly. Tags also enable budget alerts per project, so you can catch runaway spend early.

Habit 2: Set Budgets and Alerts (Then Actually Read Them)

Most cloud providers let you set budgets and alerts. Configure them for your monthly spend and for each tagged project. Set alerts at 50%, 80%, and 100% of your budget. But here's the catch: alerts only work if you act on them. When you get a 80% alert, don't just acknowledge it. Spend 10 minutes checking what's driving the spike.

# AWS example: create a budget via CLI
aws budgets create-budget --account-id 123456789012 --budget file://budget.json
Enter fullscreen mode Exit fullscreen mode

In budget.json, define the amount and the alert thresholds. It's tedious to set up, but it's a one-time cost that pays off every month.

Habit 3: Schedule Non-Production Resources Off

Development and staging environments don't need to run 24/7. If your team works 9-to-5, why are your dev servers running at 2 AM? Use instance schedules to stop resources outside working hours. Most cloud providers have native scheduling tools, or you can use a simple cron job with the CLI.

# Stop an EC2 instance at 7 PM UTC every weekday
0 19 * * 1-5 aws ec2 stop-instances --instance-ids i-1234567890abcdef0
# Start it at 7 AM UTC
0 7 * * 1-5 aws ec2 start-instances --instance-ids i-1234567890abcdef0
Enter fullscreen mode Exit fullscreen mode

This habit alone can cut dev costs by 60-70%. Just make sure you have a process to handle stateful data, like using snapshots before stopping.

Habit 4: Right-Size Before You Scale

Before you add more instances, check if your current ones are over-provisioned. Cloud providers have tools like AWS Compute Optimizer or Azure Advisor that recommend sizes based on actual usage. But you can also do it manually: look at CPU and memory metrics over a week. If your instance is at 10% CPU, downgrade it.

# Check average CPU utilization for an instance (AWS)
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-1234567890abcdef0 --start-time 2024-01-01T00:00:00Z --end-time 2024-01-08T00:00:00Z --period 3600 --statistics Average
Enter fullscreen mode Exit fullscreen mode

Right-sizing is not a one-time thing. Do it quarterly. Your workload changes, and your instances should too.

Habit 5: Review Inactive Resources Monthly

We all forget to delete things. Old load balancers, unattached volumes, orphaned snapshots. These are silent money leaks. Make a monthly calendar reminder to check for resources with zero traffic or zero usage.

# List unattached EBS volumes (AWS)
aws ec2 describe-volumes --filters Name=status,Values=available --query 'Volumes[*].{ID:VolumeId,Size:Size}' --output table
Enter fullscreen mode Exit fullscreen mode

Delete them. If you're nervous, take a final snapshot and delete after a week. You'll be surprised how much you find.

Make It a Team Habit

These habits work best when they're shared. Put cost reviews on your team's calendar. Share the monthly bill and discuss the top three costs. Make it a game: who can find the most wasted resources? The goal isn't to become a penny-pincher; it's to make sure every dollar you spend is actually helping your product.

Start Small, Win Big

You don't need to implement all five habits at once. Pick one, like tagging or scheduling, and do it this week. Then add another next month. The cloud bill won't drop overnight, but in three months you'll see a real difference. And you'll never go back to the old way.

Remember, cloud costs are not a mystery. They're a result of your habits. Change the habits, and you change the bill.

Top comments (0)