Keeping Billing Infrastructure Costs Linear With Revenue

Why we run the entire UsageBox stack on serverless services and what that does to the ops budget.

6 min read

cloud cost optimizationserverless scalinginfrastructure efficiency

Our first billing backend ran on two n1-standard-4 instances and a manually tuned Postgres cluster. It cost real money even when customers were asleep. Moving to UsageBox’s serverless stack cut the bill and the on-call rotation. Here’s how the numbers worked out.

Cost Profile Before the Switch

  • Two always-on VM instances: ~$420/month
  • Managed Postgres with replicas: ~$300/month
  • Monitoring, backups, patch windows: a few engineer days every sprint

None of that spend moved with revenue. Idle weekends cost the same as peak launches.

Serverless Tradeoffs

  • Cloud Run: scales to zero. We pay only for CPU seconds while handling ingestion bursts.
  • Firestore: storage and read/write costs track directly with event volume.
  • Pub/Sub + Cloud Tasks: cheap queueing with built-in retry logic so we stopped running our own workers.

The infrastructure bill now follows usage curves instead of staying flat.

Numbers After Migration

  • 10k events/month ≈ $40 all-in
  • 1M events/month ≈ $260 (mostly Firestore writes and reads)
  • No VM patching, no database failover drills, no weekend pager duty

We still budget for spikes, but Cloud Run handled a 12x launch-day surge without intervention. The alternative would have been over-provisioning instances just in case.

How to Keep Costs Predictable

  1. Track ingestion volume and average event size weekly, Firestore billing is sensitive to payload size.
  2. Batch tiny events when possible. We aggregate noisy signals into five-second windows to avoid write amplification.
  3. Set alerts on Cloud Run concurrency so you know when to bump limits before throttling kicks in.
  4. Export usage metrics to BigQuery or your warehouse to compare infrastructure spend against billing revenue.

Serverless won’t always be the cheapest option, but for elastic workloads like metering it keeps costs and maintenance aligned with the value you deliver.

Key Topics

  • cloud cost optimization
  • serverless scaling
  • infrastructure efficiency

Related Articles

Explore more articles on similar topics to deepen your understanding of usage-based billing.

The Fable 5 Usage-Credits Switch (July 20): the 50% Rule, the Math, and the July 17 False Alarm

Included Fable 5 access on Claude subscriptions ends July 19, 2026; from July 20 every Fable 5 token beyond the plan's i...

9 min readRead more

AI Credits Are the New Pricing Primitive: Three Cutovers in Seven Weeks (GitHub, OpenAI, Anthropic)

Between June 1 and July 20, 2026, GitHub, OpenAI, and Anthropic all moved flagship products onto credit-based metering: ...

10 min readRead more

Sonnet 5 Intro Pricing Ends August 31: The +50% Flip and the August Checklist

Claude Sonnet 5 launched June 30, 2026 at introductory pricing - $2 per million input tokens, $10 per million output, th...

8 min readRead more

Explore More Articles

Discover our complete collection of usage-based billing guides and implementation patterns.

View all articles