Loading…
Implementing scalable metered billing with Stripe: How Edgee handles billions of events
Alex Casalboni
- Source
- Stripe
- Published
- Added to Yomu
Summary
Edgee needed usage-based billing for a business combining flat-rate subscriptions with charges for proxy requests and delivered data events, while processing billions of monthly requests across more than 100 edge locations. Its architecture captures web data at the edge through a proxy and records raw metering data centrally in Google BigQuery. To control several terabytes of data, Edgee aggregates usage by tenant and sends hourly Stripe meter events through AWS Lambda, with graduated pricing and idempotency handled by Stripe. A Go configuration defines meters, prices, flat-rate plans, and pricing tiers, while retry logic and idempotent updates support resilience during disruptions. The resulting billing system remains stateless and low-latency while providing accurate monthly invoicing and a simple hosted customer interface.
Context
Edgee combines flat-rate monthly fees with high-volume usage billing for proxy requests and data events. Its globally distributed infrastructure processes billions of monthly requests across more than 100 Points of Presence, producing several terabytes of raw metering data that must be aggregated for tenant invoicing.
Approach / What changed
Edgee defines Stripe meters, products, prices, customers, and subscriptions, then stores raw usage centrally in Google BigQuery. Hourly AWS Lambda jobs pre-aggregate requests and delivered events per tenant before sending Stripe Billing Meter Events. Stripe handles graduated pricing, billing-cycle calculations, and idempotency, while Edgee uses retry logic and idempotent updates for resilience.
Takeaways
- Raw usage is centralized in Google BigQuery and pre-aggregated before reporting, avoiding the need to send every event to Stripe.
- Hourly meter events report each tenant's total requests and delivered events, allowing Stripe to apply graduated pricing at the end of the billing cycle.
- The integration combines a simple hosted billing portal with backend support for tenant-specific metering, graduated tiers, coupons, trials, retries, and idempotent updates.