Introduction
Complex Event Processing (CEP) is a critical technology for real-time applications such as high-frequency trading, network security monitoring, and sensor-based IoT systems. These systems are designed to detect specific sequences or patterns of events—for instance, "Event A followed by Event B, then Event C"—within high-velocity data streams. To maintain high throughput, CEP engines rely on optimized evaluation plans. However, the optimal plan depends heavily on the statistical properties of the input streams, which are often non-stationary. This paper presents an invariant-based approach to adaptive CEP that ensures optimal performance with minimal reoptimization overhead.
The Challenge of Dynamic Data
The efficiency of a CEP engine is determined by its evaluation plan, which dictates the order and method of matching incoming events. For example, if "Event C" occurs rarely, an efficient plan might wait for C to appear before searching for preceding A and B events, thereby conserving memory and CPU cycles.
In dynamic environments, the arrival rates of events can shift. A plan that was optimal yesterday may become a bottleneck today. Existing adaptive CEP systems typically employ one of two strategies:
- Unconditional Reoptimization: Periodically re-running the optimizer. This is computationally expensive and often results in no plan change if the statistics haven't shifted significantly.
- Constant Thresholds: Re-optimizing only when a statistic changes by a fixed percentage (e.g., 20%). This "one-size-fits-all" approach often misses subtle but impactful shifts or triggers unnecessary updates for shifts that don't change the optimal plan.
The Invariant-Based Approach
The authors propose a method based on invariants—logical constraints derived directly from the decision-making process of the optimization algorithm.
Invariant Creation and Monitoring
When an optimizer selects a plan, it makes a series of choices based on current statistics (e.g., "Plan X is better than Plan Y because the arrival rate of C is lower than B"). These choices are recorded as invariants. The system then identifies the "weakest link"—the invariant closest to being violated—and monitors it.
The researchers formally prove that as long as these invariants hold, the current plan remains the best possible plan the algorithm can produce. A violation of an invariant is a guaranteed signal that a superior plan exists, effectively eliminating "false positive" reoptimizations.
System Architecture
The proposed adaptive mechanism integrates into the standard CEP pipeline. As shown in the architecture below, a Statistics Collector monitors the input streams. The Optimizer uses these statistics to generate evaluation plans and their associated invariants. The Evaluation Mechanism executes the current plan while the system monitors for invariant violations.
To prevent "thrashing"—frequent plan switching when two options have nearly identical costs—the authors introduce distance-based invariants. This adds a stability parameter ($d$), requiring a significant enough statistical shift to justify the overhead of deploying a new plan.
Experimental Evaluation
The method was evaluated using two real-world datasets:
- Vehicle Traffic Dataset: 13.5 million events from sensors in Aarhus, Denmark, characterized by high skew and occasional extreme shifts.
- NASDAQ Stock Market Dataset: 80.5 million events from 2,100 stocks, representing a low-skew environment with frequent, small statistical fluctuations.
Key Results
- Throughput: In the traffic dataset, the invariant-based method achieved throughput 2 to 25 times higher than non-adaptive methods.
- Efficiency: While unconditional reoptimization consumed up to 11% of execution time, the invariant method's overhead remained below 1%.
- Precision: The method consistently outperformed threshold-based approaches by identifying critical plan-changing shifts that fixed thresholds would ignore, while avoiding unnecessary updates for large shifts that did not affect plan optimality.
Conclusion
By tying the adaptation trigger to the internal logic of the optimizer, this research provides a mathematically grounded way to handle non-stationary data streams in CEP. The approach is algorithm-agnostic, performing well on both NFA-based and tree-based evaluation models. Future work includes extending this to multi-pattern optimization and developing automated methods for tuning the stability distance parameter.
Summary updated