Implementing scalable metered billing with Stripe: How Edgee handles billions of events

/Article

Implementing metered billing might sound straightforward, until your system starts processing billions of requests per month across a globally distributed architecture. That's exactly the challenge faced by Edgee, a startup building a specialized proxy to help companies reclaim lost web analytics data. This article explores how Edgee designed a scalable, usage-based billing system using Stripe's metering and billing APIs, manages complexity across 100+ edge locations, and ensures accuracy and resilience in a critical part of their infrastructure.

Understanding web data loss at scale

"Chances are, you're missing up to 50% of your analytics and conversions data, and making decisions based on incomplete or wrong information." —Alex, Developer Advocate @ Edgee

The modern web is more opaque than it appears. Between ad blockers, cookie fatigue, legacy tech deprecation, and privacy regulations like General Data Protection Regulation (GDPR), many websites are blind to the majority of user actions. Here's what Edgee found:

  • Ad blockers have quadrupled in adoption over the last decade, often blocking even first-party analytics
  • Consent banners lead to significant opt-outs, with only 30% of users accepting cookies on average
  • Client-side Software Development Kits (SDKs) are used by 99% of analytics platforms and fail silently when scripts or API calls are blocked

Almost 60% of global traffic is generated by mobile devices while on the go, using unstable connections

The problem isn't the analytics platform itself, but where the data is captured. Most tracking happens in the browser, where web developers have little control. The solution is simple but powerful: shift the data collection logic from the unreliable client to the edge, where it's faster, safer, more sustainable, harder to block, and privacy-compliant.

From client to edge: rethinking web data capture

Edgee shifts data collection logic to the edge. In practice, Edgee acts as a proxy in front of your site, handling Domain Name System (DNS) and Transport Layer Security (TLS) transparently, while capturing data before the page even loads in the visitor's browser.

This architecture has several advantages:

  • No reliance on client-side JavaScript for key tracking events such as page views and conversions
  • Event forwarding happens before the browser sees the page or via the Edgee SDK for browser events
  • Open source and transparent proxy and components ecosystem
  • Multi-purpose support: not just analytics, but also consent management, warehousing, A/B testing, and more
  • Extensibility powered by first-party and third-party WebAssembly components via the Edgee Component Registry.

Edgee integrates with tools like Google Analytics, Segment, Amplitude, Posthog, ClickHouse, and many other analytics platforms and cloud services. Not replacing them, but making them more effective while allowing website owners to respect their visitors' privacy.

"We're not trying to replace Google Analytics. We're making it work the way it was meant to, while respecting privacy and regulations." —Sacha Morard, Co-founder of Edgee.

image 1

Metering at scale: building usage-based billing with Stripe

Edgee's business model combines flat-rate monthly fees with high-volume usage billing, similar to cloud platforms. The key dimensions are:

  • Requests flowing through the proxy (similar to Content Delivery Network (CDN) traffic)
  • Data events delivered to analytics platforms, data warehouses, or cloud services

The setup and tenant configuration is pretty straightforward:

  1. Create Meter objects via API (once), one for the two dimensions
  2. Create Product and Price objects via API (once, but can be customized per tenant)
  3. Create a Customer and Subscription object for each tenant
  4. At runtime, send Meter Event objects

Running on CDNs like Fastly and Cloudflare, Edgee processes billions of monthly requests, across 100+ Points of Presence (PoPs), requiring precise, distributed metering. The raw metering data is stored centrally on Google BigQuery to simplify internal analysis and reporting.

Because this is several terabytes of data, it needs some form of aggregation. Instead of pushing all raw events to Stripe, Edgee pre-aggregates it before reporting hourly meter events. This combination of centralized logging, optimized pre-aggregation, and hourly jobs running on AWS Lambda ensures low-latency, resilience, and accuracy.

Raw meter events need to be summed up to compute each tenant's invoice for their monthly consumption. Stripe natively handles idempotency and tiered pricing (graduated), taking care of all the math and edge cases at the end of each tenant's billing cycle. That means Edgee just sends the hourly total requests and events per tenant, and Stripe does the rest. This allows Edgee to keep the billing system simple and stateless.

Here a code extract that shows how the pricing model can be defined centrally (in Go):

var stripeProducts = map[string]StripeProduct{ "Events": { MeterName: "edgee_events_meter", PriceName: "edgee_events_price", Pricing: []PricingDataSet{ {From: 0, To: 0.05, PricePerUnit: 0}, {From: 0.05, To: 5, PricePerUnit: 0.009}, {From: 5, To: 50, PricePerUnit: 0.0045}, {From: 50, To: 500, PricePerUnit: 0.0023}, {From: 500, To: 0, PricePerUnit: 0.0010}, }, }, "Requests": { MeterName: "edgee_requests_meter", PriceName: "edgee_requests_price", Pricing: []PricingDataSet{ {From: 0, To: 0.5, PricePerUnit: 0}, {From: 0.5, To: 5, PricePerUnit: 0.00045}, {From: 5, To: 50, PricePerUnit: 0.000225}, {From: 50, To: 500, PricePerUnit: 0.000115}, {From: 500, To: 0, PricePerUnit: 0.000050}, }, }, "Edgee Team Plan": { PriceName: "edgee_team_price", FlatPrice: 12000.0, }, "Edgee Enterprise Plan": { PriceName: "edgee_enterprise_price", FlatPrice: 150000.0, }, }

And how aggregated meter events are sent every hour:

func BillCustomerRequests(customerId string, requestCount int, timestamp int64) error { params := &stripe.BillingMeterEventParams{ EventName: stripe.String("edgee_requests_meter"), Payload: map[string]string{ "stripe_customer_id": customerId, "value": fmt.Sprintf("%d", requestCount) # hourly consumption value }, Timestamp: stripe.Int64(int64(timestamp)), # unique timestamp for idempotency } result, err := meterevent.New(params) return err }

Lessons from the integration: resilience, flexibility, and simplicity

Edgee approached their Stripe integration with a pragmatic, phased strategy that balanced simplicity on the surface with sophistication under the hood. On the frontend, they kept things clean and intuitive, just a couple of buttons and Stripe's hosted billing portal to give customers easy, self-service access.

Behind the scenes, however, they built a robust backend: a metering pipeline tailored to each tenant, support for complex pricing structures like graduated tiers, coupons, and trials, and a design focused on resilience. They implemented retry logic and idempotent updates to ensure reliability, even during cloud disruptions or API outages.

One piece of advice they offer to others: "Invest in your metering. It moves from 'nice dashboard' to mission-critical billing fast."

Looking ahead, Edgee is already working on new capabilities, including guardrails and spend alerts, pre-paid credit models, and customer-driven preferences like unified monthly billing.

Conclusion

Edgee's implementation of usage-based billing shows how startups can manage massive scale with a clear technical strategy. By capturing data at the edge and pairing it with Stripe's flexible billing APIs, they built a system that stays simple for users while handling billions of events behind the scenes.

Their use of serverless metering, centralized logging, and pre-aggregated usage reporting enables accurate, low-latency billing across 100+ edge locations. Stripe handles pricing logic, retries, and idempotency, allowing Edgee to stay stateless and resilient, even during outages.

For technical teams, the key takeaway is clear: metering isn't just about visibility, it's infrastructure. With the right foundation, as Edgee shows, it becomes a powerful, reliable driver of revenue and product flexibility.

Catch more details in the companion interview with Alex Casalboni on the Stripe Developers YouTube channel.

/About the author

Alex Casalboni

Alex is a software engineer passionate about web technologies and music. He began working on web projects and sharing his experiences in 2011. His passion for programming spans different languages such as Python, JavaScript, and Rust, as well as the open-source and startup worlds. After spending 6 years helping developers and companies adopt cloud technologies, Alex returned to the startup life to help businesses adopt edge computing technologies powered by WebAssembly, focusing on product development and developer advocacy.