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

Discover how Edgee built a scalable, usage-based billing system processing billions of requests across 100+ global edge locations. Learn how they leverage Stripe’s metering and billing APIs to ensure accurate, resilient invoicing in a complex distributed architecture, all while solving critical web analytics data loss challenges.

Alex Casalboni
6 min readadvanced
--
View Original

Overview

This article discusses how Edgee implemented a scalable metered billing system using Stripe to handle billions of events across a globally distributed architecture. It highlights the challenges of web data loss and the innovative solutions Edgee employed to ensure accurate data capture and billing.

What You'll Learn

1

How to implement a metered billing system using Stripe's APIs

2

Why capturing data at the edge improves analytics accuracy

3

When to use pre-aggregation for billing events

Prerequisites & Requirements

  • Understanding of usage-based billing models
  • Familiarity with Stripe's billing APIs

Key Questions Answered

How does Edgee handle metered billing for billions of events?
Edgee uses Stripe's metering and billing APIs to create Meter objects for tracking requests and data events. They pre-aggregate raw meter events before reporting hourly totals to Stripe, ensuring accurate billing while maintaining a stateless architecture.
What challenges does Edgee face with web data loss?
Edgee identified that up to 50% of analytics data can be lost due to ad blockers, cookie fatigue, and privacy regulations. This data loss necessitates a shift in data capture from client-side to edge-based solutions for improved reliability.
What are the advantages of Edgee's architecture?
Edgee's architecture allows for data collection before the page loads in the visitor's browser, eliminating reliance on client-side JavaScript. This results in faster, more reliable data capture and supports various functionalities like consent management and A/B testing.
How does Edgee ensure billing accuracy and resilience?
Edgee implements a metering pipeline with retry logic and idempotent updates to handle disruptions. They aggregate data before sending it to Stripe, which manages pricing logic and ensures accurate billing at the end of each cycle.

Key Statistics & Figures

Monthly requests processed
billions
Edgee processes billions of requests monthly across over 100 Points of Presence.
Analytics data loss
up to 50%
Edgee estimates that many websites are missing up to 50% of their analytics and conversions data.
Mobile traffic generation
almost 60%
Nearly 60% of global traffic is generated by mobile devices, which often use unstable connections.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Implement a metering system that captures data at the edge to enhance analytics reliability.
By moving data collection from client-side to edge locations, you can reduce the impact of ad blockers and improve data accuracy, which is crucial for informed decision-making.
2
Utilize pre-aggregation techniques for billing events to optimize performance.
Pre-aggregating data before reporting to billing systems like Stripe can significantly reduce the volume of data processed, leading to lower latency and more efficient billing operations.
3
Invest in building a resilient billing infrastructure that can handle disruptions.
Incorporating retry logic and idempotent updates ensures that your billing system remains reliable, even during API outages or cloud service disruptions.

Common Pitfalls

1
Failing to account for data loss due to client-side tracking methods.
Many analytics platforms rely on client-side JavaScript, which can be blocked by ad blockers or consent banners. This can lead to significant gaps in data collection, impacting decision-making.
2
Overcomplicating the billing system with unnecessary features.
A complex billing system can lead to increased maintenance overhead and potential errors. Keeping the system simple and leveraging existing tools like Stripe can streamline operations.

Related Concepts

Usage-based Billing
Data Capture Strategies
Edge Computing
Analytics Accuracy