Design streaming window average processor
Event Processor Design: Sliding Window Average
Design an event processor capable of handling an infinite stream of events. Each event is defined by an id, timestamp, payload, and checksum.
The processor must fulfill the following requirements:
- Checksum Validation: Validate the
checksumfor each incoming event. - Out-of-Order Handling: The event stream is guaranteed to be out-of-order.
- Windowing: Discard any events that arrive outside a 60-second window relative to the current processing time.
- Average Calculation: Continuously maintain the average
payloadlength over the current 1-minute sliding window. - Time Complexity: The overall time complexity for processing events and maintaining the average must be O(n log n), where 'n' is the number of events currently within the window.
AI interview prep
Core dilemma
Balancing the need to efficiently process an infinite, out-of-order event stream with strict time complexity constraints, while accurately maintaining a sliding window average and managing memory for buffered events.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design streaming window average processor
Event Processor Design: Sliding Window Average
Design an event processor capable of handling an infinite stream of events. Each event is defined by an id, timestamp, payload, and checksum.
The processor must fulfill the following requirements:
- Checksum Validation: Validate the
checksumfor each incoming event. - Out-of-Order Handling: The event stream is guaranteed to be out-of-order.
- Windowing: Discard any events that arrive outside a 60-second window relative to the current processing time.
- Average Calculation: Continuously maintain the average
payloadlength over the current 1-minute sliding window. - Time Complexity: The overall time complexity for processing events and maintaining the average must be O(n log n), where 'n' is the number of events currently within the window.