Event Time vs Processing Time in Flink -Why it matters more than you think

· Source: Data Engineering on Medium · Field: Technology & Digital — Software Development & Engineering, Data Science & Analytics, Cloud Computing & IT Infrastructure · Depth: Intermediate, quick

Summary

Apache Flink jobs often produce "confidently wrong" numbers if the distinction between event time and processing time is not understood. Every event has three timestamps: event time (when it occurred in the real world), processing time (when Flink processes it), and ingestion time (when Flink ingests it from the source). The author recounts an experience where per-minute counts in a Near Real-Time (NRT) pipeline were consistently inaccurate, off by a noticeable margin, due to relying on processing time. This discrepancy directly correlated with Kafka consumer lag. For accurate results, particularly when events arrive out of order or with delays, Flink requires event time processing, which necessitates the use of watermarks to manage event ordering and completeness.

Key takeaway

For Data Engineers building or maintaining Flink streaming pipelines, explicitly choosing event time processing is critical for data accuracy. Relying on processing time, especially with variable source lag like Kafka consumer delays, will produce consistently incorrect metrics. You must implement watermarks to correctly handle out-of-order events and ensure your analytical results reflect real-world occurrences, preventing confidently wrong downstream data.

Key insights

Relying on Flink's processing time for stream analytics can yield confidently wrong results, necessitating event time for accuracy.

Principles

In practice

Topics

Best for: Data Engineer, MLOps Engineer, Software Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Data Engineering on Medium.