Cloud Cost Optimization / FinOps
Understand, track and reduce the cloud bill without hurting performance, with engineering, finance and business working together.
64.1 Why is it used?
- The cloud is 'pay as you go'. One forgotten big server or NAT/egress traffic can eat lakhs of rupees a month.
- You scaled up for sale day but forgot to scale down later: the bill for idle resources keeps running.
- Without tagging and cost allocation you do not know how much each team/service spent.
- For startups the cloud bill can be the biggest expense. A 30-40% saving is straight profit.
- Unit economics: tracking 'cost per order' or 'cost per stream hour' is essential for business decisions.
64.2 How it works
- 1.Compute 50%
- 2.Data transfer 20%
- 3.Storage 15%
- 4.Other 15%
First see tag-wise where the money goes, then apply the lever for each slice
- 1.24x7 baseline (40 servers): Savings Plan / Reserved Instance, 1-3 year commit, up to ~72% discount
- 2.Normal-day up-and-down load: On-demand + autoscaling
- 3.Sale spikes, batch, CI: Spot (Karpenter brings a new node), up to 90% cheaper, 2-min notice
Mistakes: running a DB/critical server on Spot, buying RIs for the peak, ignoring NAT/cross-AZ cost
- 1.Right-size: 30% of servers at only 10% CPU -> a smaller instance (Compute Optimizer)
- 2.Schedule: dev/test off from 10 PM to 8 AM
- 3.Data transfer 20%: images/video through the CDN (less origin egress + load), chatty services in the same AZ (avoid cross-AZ charges), VPC endpoints, watch NAT
- 4.Storage 15%: S3 Standard (new data) -> Standard-IA (after 30 days) -> Glacier (logs older than 90 days)
- 5.Visibility / showback: team / service / env tags on every resource, a namespace-wise team bill with Kubecost / OpenCost, Budgets + anomaly alerts
- 6.Result: the bill is ~40% lower, Rs 1 crore -> ~Rs 60 lakh / month, same performance
- Right-sizing: if CPU use is 10%, take a smaller instance; size by looking at metrics (CloudWatch/Compute Optimizer).
- Autoscaling: add/remove servers according to traffic; shut down dev/test environments at night (schedule).
- Spot Instances: unused capacity is very cheap (up to 90% less than on-demand), but can be taken back on 2 minutes' notice. For stateless/batch work.
- Reserved Instances & Savings Plans: a 1 or 3 year commitment, a big discount on steady baseline load (up to ~72%).
- Storage tiers: S3 Standard -> Standard-IA -> Glacier lifecycle rules; old logs/backups go to cheaper storage.
- CDN offload: serve images/videos from the CDN, reducing origin load and data transfer cost.
- Egress cost: data transfer towards the internet and cross-AZ/cross-region is paid. Keep chatty services in the same AZ and use VPC endpoints.
- Tagging & showback: team/service/env tags on every resource, then show each team its own bill; budgets and anomaly alerts.
64.3 Tools you can use
| Tool | Type | How it is used |
|---|---|---|
| AWS Cost Explorer | Cost analysis (AWS) | Service/tag wise bill, forecasts, RI/Savings Plan recommendations; works with AWS Budgets and Cost Anomaly Detection. |
| Azure Cost Management + Billing | Cost analysis (Azure) | Subscription/resource group/tag wise cost, budgets, alerts and Azure Advisor's right-sizing suggestions. |
| Kubecost / OpenCost | Kubernetes cost allocation | Shows cost at namespace/deployment/pod level: how much each team is consuming in a shared cluster. |
| AWS Compute Optimizer | Right-sizing | Looks at EC2, EBS and Lambda usage metrics and recommends a smaller/right size. |
| Karpenter / Cluster Autoscaler | K8s node autoscaling | Adds/removes nodes based on pending pods, with a spot + on-demand mix. |
| S3 Lifecycle / Intelligent-Tiering | Storage tiering | Automatically moves objects to IA/Glacier tiers according to access pattern. |
64.4 Comparison: AWS Cost Explorer vs Azure Cost Management vs Kubecost
| Point | AWS Cost Explorer | Azure Cost Management | Kubecost |
|---|---|---|---|
| Scope | AWS account/org only | Azure (and limited AWS) | A Kubernetes cluster (on any cloud) |
| Granularity | Service, account, tag, resource | Subscription, RG, tag, resource | Namespace, pod, label, container |
| Recommendations | RI/Savings Plans, rightsizing | Advisor: rightsizing, reservations | Pod request right-sizing, idle nodes |
| Install | Built-in, nothing to install | Built-in | Installed in the cluster with a Helm chart |
| Cost | Console free, API calls paid | Free for Azure usage | OpenCost free, Kubecost enterprise paid |
| Best for | An overview of the AWS bill and commitments | The Azure bill and budgets | Team-wise cost in a shared K8s cluster |
64.5 When to choose which
- AWS Cost Explorer + Budgets: the first step if you are on AWS. See where the money goes.
- Azure Cost Management: built-in for Azure workloads, use it along with Advisor.
- Kubecost/OpenCost: when all services run in one shared Kubernetes cluster and the cloud bill shows only 'EC2'.
- Savings Plans/RI: for the steady 24x7 baseline; spot: for batch, CI, stateless workers; on-demand: for spikes.
- Storage lifecycle: for logs/backups that are accessed less after 30 days.
64.6 Real-world example
Scenario: cutting an e-commerce company's cloud bill by 40%.
- The monthly bill is Rs 1 crore; Cost Explorer tag-wise showed 50% compute, 20% data transfer, 15% storage.
- A 1-year Compute Savings Plan was taken on the baseline 24x7 load (40 servers). A big discount on the compute bill.
- Sale-day spikes and image processing/batch jobs went on spot instances; Karpenter brings a new node on a spot interruption.
- Compute Optimizer showed 30% of servers at 10% CPU: they were moved to a smaller instance type.
- Product images are served from the CDN: both origin egress and load dropped; chatty cross-AZ calls were brought into the same AZ.
- Logs older than 90 days go to S3 Glacier through a lifecycle rule; dev/test environments are off from 10 PM to 8 AM.
- Monthly showback to every team with Kubecost; budget alerts were set. The bill dropped by about 40% with the same performance.
64.7 Interview tips
- Running a stateful DB or a single critical server on spot: the instance will be gone in 2 minutes.
- Buying Reserved Instances for the peak load: the paid capacity sits idle the rest of the time.
- Ignoring data transfer cost: NAT Gateway, cross-AZ and egress quietly become a big part of the bill.
- Interview tip: say these FinOps pillars: 'right-size, autoscale, spot + savings plans mix, storage tiering, CDN, tagging'. Quote the numbers: spot up to 90%, Savings Plan up to ~72%, a 40% bill reduction in the example.