SkillPilotAI

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

Monthly bill Rs 1 crore: where is it going? (AWS Cost Explorer, tag-wise)
  1. 1.Compute 50%
  2. 2.Data transfer 20%
  3. 3.Storage 15%
  4. 4.Other 15%

First see tag-wise where the money goes, then apply the lever for each slice

Compute: which load goes on which pricing
  1. 1.24x7 baseline (40 servers): Savings Plan / Reserved Instance, 1-3 year commit, up to ~72% discount
  2. 2.Normal-day up-and-down load: On-demand + autoscaling
  3. 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

The other levers
  1. 1.Right-size: 30% of servers at only 10% CPU -> a smaller instance (Compute Optimizer)
  2. 2.Schedule: dev/test off from 10 PM to 8 AM
  3. 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. 4.Storage 15%: S3 Standard (new data) -> Standard-IA (after 30 days) -> Glacier (logs older than 90 days)
  5. 5.Visibility / showback: team / service / env tags on every resource, a namespace-wise team bill with Kubecost / OpenCost, Budgets + anomaly alerts
  6. 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

ToolTypeHow it is used
AWS Cost ExplorerCost analysis (AWS)Service/tag wise bill, forecasts, RI/Savings Plan recommendations; works with AWS Budgets and Cost Anomaly Detection.
Azure Cost Management + BillingCost analysis (Azure)Subscription/resource group/tag wise cost, budgets, alerts and Azure Advisor's right-sizing suggestions.
Kubecost / OpenCostKubernetes cost allocationShows cost at namespace/deployment/pod level: how much each team is consuming in a shared cluster.
AWS Compute OptimizerRight-sizingLooks at EC2, EBS and Lambda usage metrics and recommends a smaller/right size.
Karpenter / Cluster AutoscalerK8s node autoscalingAdds/removes nodes based on pending pods, with a spot + on-demand mix.
S3 Lifecycle / Intelligent-TieringStorage tieringAutomatically moves objects to IA/Glacier tiers according to access pattern.

64.4 Comparison: AWS Cost Explorer vs Azure Cost Management vs Kubecost

PointAWS Cost ExplorerAzure Cost ManagementKubecost
ScopeAWS account/org onlyAzure (and limited AWS)A Kubernetes cluster (on any cloud)
GranularityService, account, tag, resourceSubscription, RG, tag, resourceNamespace, pod, label, container
RecommendationsRI/Savings Plans, rightsizingAdvisor: rightsizing, reservationsPod request right-sizing, idle nodes
InstallBuilt-in, nothing to installBuilt-inInstalled in the cluster with a Helm chart
CostConsole free, API calls paidFree for Azure usageOpenCost free, Kubecost enterprise paid
Best forAn overview of the AWS bill and commitmentsThe Azure bill and budgetsTeam-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%.

  1. The monthly bill is Rs 1 crore; Cost Explorer tag-wise showed 50% compute, 20% data transfer, 15% storage.
  2. A 1-year Compute Savings Plan was taken on the baseline 24x7 load (40 servers). A big discount on the compute bill.
  3. Sale-day spikes and image processing/batch jobs went on spot instances; Karpenter brings a new node on a spot interruption.
  4. Compute Optimizer showed 30% of servers at 10% CPU: they were moved to a smaller instance type.
  5. Product images are served from the CDN: both origin egress and load dropped; chatty cross-AZ calls were brought into the same AZ.
  6. Logs older than 90 days go to S3 Glacier through a lifecycle rule; dev/test environments are off from 10 PM to 8 AM.
  7. 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.