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 Usage-Based Billing Vendor Landscape After the 2026 Consolidation

Stripe took Metronome, Adyen took Orb, Salesforce took m3ter. The independent metering market closed in 2026, which chan...

7 min readRead more

What a Billing API Must Actually Do (Five Requirements, In the Order They Bite)

Most billing API evaluations start at the invoice endpoint, which is the end nobody fails at. Projects fail at ingestion...

9 min readRead more

Cost Per Task, Explained: How the Metric Is Built and Where People Misread It

Cost per task replaced price per million tokens because token price says nothing about how many tokens a job needs. On t...

8 min readRead more

Explore More Articles

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

View all articles