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.

Gemini 3.8 Flash Pricing & Free Tier (October 2026)

Gemini 3.8 Flash is free on the Gemini API Free Tier and costs $0.75 input and $3.75 output per 1M tokens through Decemb...

9 min readRead more

Gemini CLI Free Tier Limits 2026: 1,000 Requests a Day

Gemini CLI limits by sign-in method as of October 2026: 1,000 requests a day with a Google account, 250 a day (Flash onl...

8 min readRead more

OpenAI Codex Pricing & Usage Limits (October 2026): Every Plan

OpenAI Codex pricing as of October 2026: Free, Go $8, Plus $20, Pro from $100, Business $20 per user, and API key billin...

9 min readRead more

Explore More Articles

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

View all articles