Apache Spark Big Data (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Spark Streaming Watermarking and Late Data Handling: Sliding vs Tumbling windows, event-time, and output modes.
senior Levelapache-sparkAdvanced Internals
In Simple Words: In streaming pipelines, network delays mean events arrive out of order:
- Event-Time: The timestamp embedded inside the record when the action occurred.
- Watermark (
withWatermark("timestamp", "10 minutes")): Tells Spark how late data can arrive before being discarded. Spark maintains window aggregation state in memory only untilmax(event_time) - 10 minutes. - Output Modes:
Append: Only finalized, completed windows are emitted downstream.Update: Emits updated aggregation values on every incoming event.Complete: Emits the entire aggregated table state on every micro-batch.