MarzleyTech Learn

Home / Learn / DevOps & cloud: from zero to deploying and running real systems / Cloud cost control (FinOps): free tiers, budgets, right-sizing and avoiding surprise bills

Cloud cost control (FinOps): free tiers, budgets, right-sizing and avoiding surprise bills

The cloud's pay-as-you-go model is powerful, and dangerous for beginners. Stories of students receiving bills of hundreds of dollars for a forgotten server are common. Cost control is part of an engineer's job; companies call it FinOps.

Before you create anything

  1. Set a budget and billing alerts (e.g. alert at $5, $10, $20).
  2. Read the free tier rules: limits on hours, storage and services; some offers last 12 months, some are always free.
  3. Pick small sizes and one region.
  4. Turn on MFA (stolen accounts are a major source of huge bills).

What usually causes surprise bills

CausePrevention
Forgotten servers and databases left runningDelete practice resources the same day; use terraform destroy
Managed Kubernetes clusters and NAT gateways (charged hourly even when idle)Delete after practice
Unattached disks, snapshots and public IPsClean up after deleting servers
Data transfer out of the cloudUse a CDN; keep traffic inside one region
Leaked access keys used for crypto-miningNever commit keys; MFA; billing alerts
Logs stored foreverSet retention periods

Saving money on real systems

TechniqueIdea
Right-sizingUse the smallest instance that meets needs; check actual CPU and memory use
Auto scalingAdd servers at busy times, remove them when quiet
SchedulingTurn off dev and test environments at night and weekends
Reserved instances / savings plansCommit for 1–3 years for steady workloads
Spot / preemptible instancesCheap capacity for jobs that can be interrupted
Storage tiersMove old backups to cheaper archive storage
ServerlessPay only when code runs, for spiky or low traffic
TaggingTag every resource (project, owner, environment) to see who spends what

How much can scheduling save? (run it)

Python · runs live in the interactive lesson
hours_in_month = 730
hourly_cost = 0.10            # example price per server-hour (USD)
servers = 4                   # a dev/test environment

always_on = hours_in_month * hourly_cost * servers
office_hours = 22 * 12        # 22 weekdays x 12 hours
scheduled = office_hours * hourly_cost * servers

print(f"Always on:      ${always_on:,.2f} per month")
print(f"Office hours:   ${scheduled:,.2f} per month")
print(f"Saving:         ${always_on - scheduled:,.2f} ({1 - scheduled / always_on:.0%})")

Turning off test servers outside office hours saves most of their cost.

Paying for cloud from Kenya

  • Cloud providers usually bill in US dollars by card. Use a debit card or a virtual card (some banks and mobile money services offer virtual cards; check fees and limits).
  • Exchange rates and card fees change your real cost; keep a buffer.
  • For businesses, check invoicing and tax requirements with an accountant.
  • Some local hosting providers bill in shillings and accept M-Pesa, which can suit small websites better than a big cloud.

A monthly cost review habit

  1. Open the billing dashboard; compare with last month.
  2. Look at the top 5 services by cost.
  3. Find idle or oversized resources.
  4. Delete, downsize or schedule.
  5. Check that alerts and budgets still match reality.
Think about it: You finish a Kubernetes tutorial on a cloud free trial and close your laptop. What might still be costing money, and what should you do?Show answer

The managed cluster's control plane, worker node VMs, load balancers, NAT gateways, disks and public IPs may all still be running. Delete the cluster and related resources (or run terraform destroy), check the billing page and resource lists in every region you used, and keep billing alerts on.

Summary

  • Set budgets and billing alerts before creating anything; know the free tier rules.
  • Surprise bills come from forgotten resources, idle clusters, data transfer and leaked keys.
  • Save with right-sizing, auto scaling, scheduling, commitments, spot capacity, storage tiers and tagging.
  • Review costs monthly; consider local, shilling-billed hosting for small sites.

Check yourself

  1. What is the practice of managing cloud costs often called? (one word)

    Show answer

    finops

  2. Should you leave practice Kubernetes clusters running overnight? (yes or no)

    Show answer

    no

  3. Using the smallest instance that meets your needs is called ___-sizing (one word)

    Show answer

    right

Lesson 13 of 14 in DevOps & cloud: from zero to deploying and running real systems · Written by · Course notes