Real-time device usage streams enable accurate usage-based billing with sub-minute granularity

We successfully implemented real-time usage-based billing for our IoT device fleet using Cumulocity’s streaming analytics. Previously, we ran nightly batch jobs that aggregated device measurements, leading to 12-24 hour billing delays and frequent disputes over usage calculations.

Our solution processes measurement streams in real-time, aggregates usage per device per minute, and triggers automated invoice generation when billing thresholds are reached. This has reduced billing disputes by 87% and improved cash flow through immediate overage detection. The streaming approach handles 50,000 devices generating measurements every 30 seconds without performance degradation.

Good questions. We’re running on Cumulocity’s multi-tenant cloud with a dedicated microservice instance for streaming analytics. The CEP engine uses about 8GB RAM and 4 vCPUs at peak load. Storage is actually lower than batch - we retain raw measurements for 7 days, then keep only the minute-level aggregates. For disputes, the aggregated data is sufficient since we’re billing at minute granularity anyway. The key optimization was using Apama’s time-based windows instead of count-based, which keeps memory usage predictable regardless of device message frequency.

We use Cumulocity’s monetization microservice for threshold detection and event generation, then push to our external billing system via REST API. The streaming aggregation writes usage summaries to a custom managed object every minute. When cumulative usage crosses tier thresholds, the monetization service emits a billing event that our integration layer forwards to the billing system. We have five pricing tiers with different per-unit costs, and the streaming analytics evaluates tier progression in real-time. This eliminated the batch job complexity where tier calculations were error-prone.

How are you handling the automated invoice triggers? Are you pushing aggregated usage data to an external billing system, or does Cumulocity’s monetization module handle the actual invoice generation? We’re considering a similar architecture but need to integrate with Salesforce Billing for our enterprise customers. Also curious about your threshold detection logic - is it purely volume-based or do you have more complex pricing tiers?

We’re using Apama CEP exclusively - no external dependencies. For late arrivals, we implemented a 5-minute watermark window that buffers events before finalizing aggregations. Out-of-order events within that window are automatically sorted by timestamp before aggregation. Events arriving after the watermark are logged separately and reconciled in our weekly adjustment process, though this represents less than 0.3% of total events.