This blog post is a companion to the real-time rating scenario placed on the Nussknacker demo site.
You can find an overview of this scenario here.
Introduction: The Need for Real-Time Rating
Rating is the process of determining the cost or value of a service based on predefined rules. It plays a crucial role in industries such as telecommunications, finance, transportation, and utilities, where services are consumed dynamically and often require immediate cost evaluation. You can find an interesting introduction to rating in this LinkedIn article.
Traditionally, rating has been performed in batch mode - collecting usage data over a period and processing it in bulk to generate bills or reports. However, in many modern applications, batch processing is insufficient. Customers expect real-time feedback on their usage and costs, and businesses need to enforce limits, apply dynamic pricing, or trigger automated actions instantly.
To meet these needs, many organizations adopt an online synchronous architecture, where each transaction triggers a rating request that updates the customer’s balance or applies necessary charges. While this approach works up to a certain point, it eventually struggles under high transaction volumes - with the grey zone starting already at 10k updates per second. The core challenge is state management: real-time rating requires continuously tracking balances, quotas, or accumulated usage across millions of customers. Even more, real-time rating is an update-heavy process which cannot benefit from the 1 master for updates - N read-only replicas db architecture. Without efficient state handling, the system cannot scale, as each request needs access to the latest state before processing can continue. This is where stateful stream processing emerges as a necessary evolution.
Why Synchronous Architectures Become Insufficient
In an online rating system using a synchronous architecture, every service consumption event (e.g., a telecom customer using mobile data) triggers a synchronous interaction with a backend rating engine. This engine checks the customer’s current balance, applies the necessary charges, and updates the balance accordingly.
While this model works initially, it introduces several limitations as usage scales:
- Bottlenecks in Database Access - Each transaction requires a lookup and update in a central database, leading to high contention and limiting scalability.
- Latency Issues - Real-time rating must be fast, but synchronous requests introduce delays, especially when network or database response times fluctuate.
- Expensive horizontal scaling - Database horizontal scaling is an involving task, both for the database team and the development team: rebalancing shards is manual and can be painful, and applications have to be sharding aware.
You can read more about the limitations of the synchronous architecture here.
A more scalable alternative is stateful stream processing, which allows rating decisions to be made continuously, without constant database interactions.
How Stateful Stream Processing Addresses These Challenges
Stateful stream processing frameworks, such as Apache Flink, allow rating calculations to happen in real-time, maintaining balances or usage quotas in the distributed state rather than relying on repeated database lookups. This approach brings several advantages:
- Efficient State Management - Instead of querying a database for each event, the system maintains an in-memory, distributed state that holds customer balances, quotas, or other relevant data. This reduces contention and improves throughput.
- Low Latency Processing - Since state updates happen within the streaming system itself, there is no need for blocking database calls, significantly reducing response times.
- Better Scalability - Stateful streaming allows rating computations to be partitioned across multiple nodes, enabling parallel processing. Partitioning of the processing is handled by the stateful processing engine (for example Flink), there is no need to build application logic to deal with this partitioning.
- Smaller Resource Requirements -under heavy updates intensity (the grey zone starts at ~10k updates/sec), even if the synchronous system is heavily optimized (caching, using in-memory DB like Redis, database sharding), the stateful stream processing solution will require fewer resources.
- Complex Event Processing - if input to rating contains very low level events, detection of event patterns may be necessary to decide whether a particular sequence of events forms a rateable event.
You can read more about technology challenges solved by stateful stream processing here.
Real-World Use Cases of Stateful Stream Processing in Rating Systems
- Telecommunications (Ericsson, Vodafone, etc.) - Telecom providers use real-time rating for voice, SMS, and data services. Instead of querying a database for every data usage event, a stateful stream processing system maintains each customer’s balance and deducts usage instantly. This prevents overages and ensures prepaid users are charged correctly without delays.
- Ride-Hailing (Uber, Lyft) - Pricing for rides dynamically adjusts based on demand, distance, and surge pricing models. Stateful stream processing helps track ongoing rides, apply real-time pricing adjustments, and ensure customers and drivers receive immediate cost feedback.
- Digital Advertising (Google Ads, Meta Ads) - Real-time bidding (RTB) platforms require instantaneous budget tracking for advertisers. Stateful stream processing ensures that ad spending is updated in real time, preventing overspending and optimizing campaign performance.
- Energy and Utilities (Smart Metering, Dynamic Pricing) - Utility providers dynamically calculate costs based on real-time energy consumption and fluctuating market rates. Stateful processing enables instant price adjustments and alerts customers when they reach predefined usage limits.
How Nussknacker Can Help in Real-Time Rating
Implementing a stateful stream processing rating system requires a platform that simplifies the development and operationalisation of real-time data pipelines while ensuring flexibility and scalability. Nussknacker is designed to address these needs by enabling both technical and non-technical users to build and manage stream processing logic efficiently.
With its low-code approach, Nussknacker allows teams to define complex event processing logic visually while still offering the extensibility to integrate custom components where needed. This makes it easier to implement real-time rating rules, handle stateful computations (such as session-based billing or cumulative usage tracking), and react to data streams with minimal latency. Additionally, built-in support for Apache Flink ensures that computations scale effectively, even as data volumes grow.
For organizations transitioning from traditional architectures to stateful stream processing, Nussknacker provides a balance between ease of use and technical depth - allowing rapid prototyping, iterative improvements, and seamless deployment of real-time rating logic without sacrificing control over the underlying data flows.