Cost Visibility as a Precondition for Reliability
Cost monitoring revealed reliability issues invisible to traditional observability. What started as a FinOps initiative became the foundation for operational excellence.
[Overview] System Overview
Cloud bills arrive monthly. Engineering teams know the total spend. They rarely know what drives it. When bills spike, the question is always the same: what changed?
This case examines how implementing cost visibility for a B2B SaaS platform revealed reliability issues that traditional monitoring had missed. The platform served four product lines across 40 microservices, with infrastructure costs growing 15% quarterly without clear attribution.
Cost visibility is not a finance concern. It is an engineering capability. The patterns that drive cost often correlate with the patterns that degrade reliability. A batch job exhausting database connections shows as a compute cost spike. An S3 transfer anomaly indicates a background task misbehaving. Memory leaks manifest as instance churn.
The insight was unexpected: building cost attribution exposed more operational issues than the entire observability stack had surfaced in the previous year.
[Context] Situation before
The engineering team was not negligent. They had CloudWatch dashboards, Datadog APM, and PagerDuty alerts. What they lacked was the ability to ask: which service, which customer, which feature is responsible for this $12,000 line item?
##### Monthly Bill Shock
AWS bills arrived showing totals by service type: EC2, RDS, S3, Lambda, data transfer. These categories meant nothing operationally. The team could see that EC2 cost $85K but could not determine which of the 40 services consumed it.
Budget conversations happened monthly. They were reactive. The CFO asked why costs increased 18%. Engineering guessed. Nobody was lying. Nobody actually knew.
##### Invisible Cost Drivers
The largest customer paid $15K annually. Their infrastructure cost was $8K monthly. This was not visible. Pricing was based on seat count. Usage was irrelevant to the commercial model but critical to unit economics.
Some features cost 10x more than others to operate. The product team could not factor this into roadmap decisions. Engineering could not advocate for optimization because they could not quantify the impact.
##### Reliability Issues Hidden in Noise
The team had experienced several incidents where the root cause remained unclear. A database connection exhaustion issue resolved itself before debugging completed. An S3 rate limit error appeared during a traffic spike but could not be attributed to a specific service.
Post-mortems concluded with "we added more capacity" rather than "we understood the root cause." This pattern repeated quarterly.
[Diagnosis] The Real Problem
The visible problem was unpredictable cloud costs. The obvious solution was to hire a FinOps analyst or subscribe to a cost optimization tool. These would provide recommendations: rightsize instances, buy reserved capacity, delete unused resources.
That approach treats symptoms. It does not build capability.
##### Why Cost Tools Alone Fail
Cost optimization tools compare your infrastructure to benchmarks. They identify waste. They cannot tell you why a service costs $4K this month when it cost $1K last month.
Recommendations like "switch to smaller instances" ignore context. The instance might be large because an unresolved issue requires headroom. Shrinking it surfaces the problem violently instead of deliberately.
##### The Deeper Issue
Cost is a signal. Like latency or error rates, changes in cost patterns indicate something changed in the system. But unlike latency, cost signals are delayed and aggregated. By the time the monthly bill arrives, the incident that caused a spike is weeks old.
The real need was not optimization. It was attribution: the ability to correlate every dollar of cloud spend with the service, environment, customer, and feature that generated it.
Attribution enables questions that optimization cannot answer. Why did this customer cost 10x more than expected? Why did this feature spike last Tuesday? Why does the staging environment cost more than production?
Understanding the root cause changed everything.
[Boundaries] Working constraints
Cost visibility sounds straightforward: tag resources and build dashboards. In practice, legacy infrastructure, shared resources, and organizational dynamics create significant complexity.
OPERATIONAL
- Resource tagging required infrastructure code changes across 40+ Terraform modules.
- Some resources (NAT gateways, load balancers) are shared and cannot be directly attributed.
- Real-time cost data is delayed 8-24 hours in AWS Cost Explorer.
- Cost allocation tags must be activated in billing settings, requiring admin access.
COST
- Additional tooling budget: $0. CFO would approve after demonstrating value.
- Engineering time budget: 20% of one platform engineer for 3 months.
- Cannot introduce expensive third-party cost management platforms.
TEAM
- No dedicated FinOps role or expertise.
- Service owners unfamiliar with cost allocation concepts.
- Finance team untrained in technical cost analysis.
MIGRATION
- Historical cost data lacks attribution. Retroactive tagging impossible.
- Existing dashboards must continue working during transition.
- Alerting thresholds based on total spend, not attributed spend.
IMMUTABLE
- AWS cost data structure and delays are fixed.
- Multi-tenant architecture shares many resources at infrastructure layer.
- Compliance requirements prevent some cost data from being exposed widely.
Constraints are features, not obstacles. They guide design decisions.
[Decisions] Key tradeoffs
We evaluated four approaches to cost visibility. Each represented a different investment level and capability outcome.
##### Key Tradeoff Accepted
Tagging provides 80% accuracy with 20% effort. Shared resources (load balancers, NAT gateways) cannot be perfectly attributed. We accepted allocation rules for shared costs: proportional to tagged resource consumption.
##### Decisions Delayed on Purpose
Showback dashboards for service owners. Needed trust in data accuracy first.
Automated optimization recommendations. Required understanding current state.
Customer-level unit economics. Needed stable attribution before customer mapping.
Chargeback policies. Political complexity avoided until value demonstrated.
REJECTED
Monthly bill review with spreadsheet allocation
Finance manually allocates costs to teams based on percentages.
Inaccurate allocation. No operational insight. Cannot drill down to service or customer level. Useful only for rough budgeting.
DEFERRED
Third-party cost management platform
Implement CloudHealth, Cloudability, or similar.
Costs $3-5K/month at our scale. Provides recommendations but still requires tagging for attribution. Evaluated as Phase 2 if homegrown approach insufficient.
CHOSEN
Tag all resources, build custom dashboards
Implement comprehensive tagging strategy using native AWS tools.
Low cost. Builds internal capability. Native integration with existing infrastructure. Enables gradual improvement.
DEFERRED
Activity-based costing with application metrics
Calculate costs from application activity rather than resource tags.
Most accurate but requires significant instrumentation. Planned for Phase 2 after tagging foundation establishes baselines.
[Design] Architecture design
The cost visibility system had three layers: data collection (tagging), data processing (ETL from Cost Explorer), and data presentation (dashboards and alerts).
##### Tagging Strategy
Four mandatory tags: service (e.g., payments-api), environment (prod/staging/dev), team (payments/platform/data), cost-center (matches finance codes).
Two optional tags: customer_tier (for resources attributable to customer segments), feature (for A/B test variations).
Tags enforced through Terraform modules. Resources without required tags fail to deploy.
##### Shared Resource Allocation
NAT gateway costs allocated proportionally to tagged resource usage per service.
Load balancer costs allocated by request count from ALB access logs.
Data transfer costs allocated by source/destination service tags where possible.
Cost Attribution Framework
Cost visibility reveals reliability issues
cost-visibility-precondition-reliability-architecture
[Approach] Execution Model
Implementation took 10 weeks. The first 6 weeks established the foundation. The final 4 weeks revealed the unexpected reliability discoveries.
##### Weeks 1-2: Tagging Infrastructure
Updated all Terraform modules to require cost allocation tags. Added tag validation to CI pipelines. Created runbook for tagging legacy resources.
Discovered: 23% of resources had no meaningful tags. Most were developer-created test resources that had persisted for months.
##### Weeks 3-4: Data Pipeline
Configured Cost and Usage Report (CUR) exports to S3. Built Athena tables for query access. Created basic QuickSight dashboards.
Discovered: Data transfer costs were 3x expected. Cross-AZ traffic between microservices was expensive and unnecessary.
##### Weeks 5-6: Dashboard Development
Built dashboards for: spend by service, spend by environment, spend by team, daily anomaly detection.
Discovered: Staging environment cost 70% of production. Nobody had noticed because it was not attributed separately.
##### Weeks 7-10: Operational Integration
Trained service owners on dashboards. Set up weekly cost review meetings. Created anomaly alerts with thresholds.
This phase revealed the reliability issues that had been invisible to traditional monitoring.
[Results] Measurable outcomes
The cost visibility initiative achieved its stated goals. But the unexpected outcomes proved more valuable.
##### Direct Cost Savings
Identified $28K/month in unnecessary spend within the first 6 weeks. Staging environment rightsized. Orphaned resources deleted. Cross-AZ traffic eliminated for read-heavy services.
Savings covered 18 months of platform engineering time invested.
##### Reliability Issues Discovered
Batch job exhausting database connections: A customer data export job running nightly was opening connections without closing them. Cost visibility showed the job costing 8x normal during peak. Investigation revealed the connection leak. Fix improved reliability for all customers.
Background task S3 explosion: A thumbnail generation service was re-processing unchanged images due to a cache invalidation bug. Cost spike on S3 operations led to discovery. Fix reduced S3 operations 90%.
Memory leak causing instance churn: An autoscaling group was replacing instances every 8 hours. Cost visibility showed consistent hourly instance costs that should have been stable. Investigation revealed memory leak in JVM heap. Fix reduced instance costs 40%.
Expensive slow query: A $8K/month query was running 200ms instead of the expected 5ms due to missing index. Cost attribution to the analytics service led to query optimization.
##### Operational Culture Change
Service owners began checking cost dashboards as part of deployment verification.
Cost anomalies became a standard incident trigger alongside latency and error rates.
Finance and engineering developed shared language for discussing infrastructure investment.
##### Unit Economics Clarity
For the first time, leadership could see cost per customer tier. Enterprise customers with custom integrations cost 5x more than self-serve customers. This informed pricing decisions without guesswork.
Key improvements achieved:
- System handles 10x burst load without degradation
- Delivery latency reduced from seconds to milliseconds
- Zero message loss during traffic spikes
- Operational complexity reduced by 60%
[Anti-patterns] What could have gone wrong
##### Without Cost Visibility
The batch job connection leak would have continued until a full outage occurred. The pattern was invisible to traditional monitoring because connections were eventually released.
The S3 thumbnail bug would have grown linearly with customer count. By the time someone noticed, costs would have doubled.
The memory leak would have continued wasting 40% of compute budget. Eventually the team would have requested larger instance types, making the problem more expensive.
##### If Using Only Third-Party Tools
Third-party tools would have recommended instance rightsizing and reserved capacity. These are correct recommendations in general. They would have hidden the root causes.
Buying reserved instances for a memory-leaking workload locks in waste. The team would have felt they were optimizing while spending more than necessary.
- Over-engineering the initial solution
- Ignoring operational constraints during design
- Premature optimization without load testing
- Skipping failure mode analysis
[Applicability] Where This Pattern Applies
##### This Approach Works Well When
Cloud spend exceeds $50K/month. Below this, the investment may not pay off.
Multiple services or teams share infrastructure.
Cost variance is unexplained month-to-month.
Reliability issues occur without clear root causes.
Finance and engineering need shared visibility into infrastructure investment.
##### This Approach Is Overkill When
Single application with simple infrastructure.
Costs are stable and understood.
Team is small enough that everyone knows what runs where.
##### Who Should Use This
Platform engineering teams in mid-size SaaS companies.
FinOps practitioners looking for engineering partnership.
CTOs seeking operational visibility without third-party tool costs.
##### Who Should Not Use This
Teams without infrastructure-as-code. Tagging retrofits are painful.
Organizations requiring immediate optimization. Building capability takes time.
Companies with dedicated FinOps teams already running mature programs.
Every system is different. Context always matters.