Structured Streaming: Choose Watermarks Around Real Arrival Delays
A practical streaming lesson: measure how late business events arrive before choosing a watermark threshold.
Consider a hypothetical retailer using Azure Databricks to calculate sales in five-minute windows. A customer completes a purchase at 10:05, but the storeโs connection fails. The event reaches the platform at 10:40, after newer sales have already arrived.
With a ten-minute watermark delay, that purchase might arrive too late to update its sales window.
Structured Streaming tracks the maximum observed event timestamp and uses the configured delay to calculate its watermark. Records within the lateness threshold are guaranteed to be processed; records outside it might still be processed, but that is not guaranteed.
For this fictional pipeline, I would:
Measure arrival delays across normal operations and store outages.
Choose a threshold that reflects the businessโs tolerance for missing late sales.
Retain original events so historical totals can be reconciled separately.
Test delayed events and monitor state growth before production.
A longer threshold tolerates more late data but retains more state. For windowed aggregations in append mode, it also delays final output.
How does your team balance timely sales reporting with accepting events delayed by outages?
Reference: Azure Databricks watermark guidance.
#Databricks #StructuredStreaming #DataEngineering
Amit Sharma