SlideShare a Scribd company logo
When Streaming
Needs Batch
-
Flink's Journey
Towards a
Unified Engine
Konstantin Knauf
–
@snntrable
–
Current 22
About Me
2
● Co-Founder @ Immerok
● Apache Flink Committer & Member of the PMC
● Formerly Head of Product & Field Engineer @ Ververica
Visit us at
booth S14.
Steady State - Streaming Heaven
3
4
Backfilling
following an outage
Backfilling
or after an introducing a bug
7
State Bootstrapping
Catch Up
Bursty Streams
Agenda
Motivation CHECK
Setting the Stage
Catching Up & Handling Bursty Streams
Backfilling
Bootstrapping
Takeaways
Setting the Stage
11
Stream Processing Batch Processing
Bounded Data CHECK CHECK
Unbounded Data CHECK
Some Terminology
Nature
of
Data
Nature of Processing
A Typical Streaming Job
Apache Kafka* in/out
* or any other replayable queue like
Apache Pulsar/AWS Kinesis/…
A Typical Streaming Job
Flink Pipeline
with multiple operators &
shuffles
A Typical Streaming Job
incl. significant state
A Typical Streaming Job
A Typical Streaming Job
A Typical Streaming Job
A Typical Streaming Job
Catching Up &
Bursty Streams
20
Scenario
There is a large backlog of data and you want to catch up to real-time again. For example,
happens when upstream producers send data in big chunks.
Wishlist
● process backlog quickly
● process backlog robustly with existing resources
Scenario
1
Backlog -> Backpressure
When under backpressure, what do you want?
● Scale up
● Or catch up steadily
Backlog -> Backpressure
When under backpressure, what do you want?
● Scale up
● Or catch up steadily
Scaling Up under Backpressure
Adaptive Scheduler and Reactive Mode (Flink 1.13)
Task Manager
Task
Slot
Task
Slot
Scaling Up under Backpressure
Adaptive Scheduler and Reactive Mode (Flink 1.13)
Task Manager
Task
Slot
Task
Slot
Task Manager
Task
Slot
Task
Slot
Scaling Up under Backpressure
Adaptive Scheduler and Reactive Mode (Flink 1.13)
Task Manager
Task
Slot
Task
Slot
Task Manager
Task
Slot
Task
Slot
● Job automatically scales up when provided with additional resources
● No additional Savepoint needed for rescaling*
* Caveat: This might still take quite some time during restore. Flink 1.16 brings some more improvements in that regard.
Backlog -> Backpressure
When under backpressure, what do you want?
● Scale up
● Or catch up steadily
Robustness under Backpressure
Watermark Alignment (Flink 1.15)
high throughput topic
low throughput topic
Robustness under Backpressure
Watermark Alignment (Flink 1.15)
advances watermark
~ with processing
time
advances watermark
~ with processing
time
Robustness under Backpressure
Watermark Alignment (Flink 1.15)
advances watermark
slowly
advances watermark
very quickly
Robustness under Backpressure
Watermark Alignment (Flink 1.15)
join state grows
during processing a
backlog
Robustness under Backpressure
Watermark Alignment (Flink 1.15)
advances watermark
slowly
advances watermark very
quickly
Robustness under Backpressure
Unaligned Checkpoints (Flink 1.11-1.13) & Buffer Debloating (Flink 1.14)
checkpoint
barrier n
6
x
5
4
3
2
1
f
e
c
d
b
a
h
g
e
f
d
c
y
9
8
7
6
5
4
a y
b
1
2
3
input buffer
aligning
begin aligning
operator operator
Robustness under Backpressure
Unaligned Checkpoints (Flink 1.11-1.13) & Buffer Debloating (Flink 1.14)
Under backpressure & at scale checkpoint alignment can take hours leading to checkpoint timeouts and job
failures.
● Buffer debloating dramatically reduces the amount of in-flight data
● Unaligned checkpoints allows barriers to overtake in-flight data
checkpoint
barrier n
6
x
5
4
3
2
1
f
e
c
d
b
a
h
g
e
f
d
c
y
9
8
7
6
5
4
a y
b
1
2
3
input buffer
aligning
begin aligning
operator operator
Scenario
There is a large backlog of data and you want to catch up to real-time again. For example, happens
when upstream producers send data in big chunks.
Wishlist
● process backlog quickly CHECK (Adaptive Scheduler)
● process backlog robustly with existing resources CHECK (Buffer Debloating, Watermark Alignment, Unaligned Checkpoints)
Scenario
Backfilling
36
Scenario
You want to reprocess a fixed amount of (recent) historical data to correct a bug or outage.
Wishlist
● Code-reuse for backfilling
● Same semantics and complete & correct results
● Resource efficient
Scenario
[1] https://www.youtube.com/watch?v=4qSlsYogALo&t=668s
1
38
- The Apache Flink Community
Batch is a Special Case of Streaming
DataStream API
with Streaming Execution
DataStream API
with Streaming Execution
DataStream API
with Streaming Execution
All the elasticity and robustness improvements for processing under backpressure apply to here, too.
Scenario
We want to reprocess a fixed amount of (recent) historical data to correct a bug or outage.
Wishlist
● Code-reuse for backfilling CHECK
● Same semantics and complete & correct results CHECK
● Resource efficient
Evaluation
Stream Execution Mode
Batch Execution Mode
Implementation Timeline
● Apache Flink 1.12
○ Initial Release
○ Unified Sink API (beta)
● Apache Flink 1.13
○ Support for Python DataStream API
● Apache Flink 1.14
○ Batch Execution Mode for mixed DataStream/Table API programs
○ Unified Sink API stable
○ Unified Source API stable
● Apache Flink 1.15
○ Most Sources/Sinks migrated to unified interfaces
○ Adaptive Batch Scheduler
DataStream API
with Batch Execution
DataStream API
with Batch Execution
DataStream API
with Batch Execution
Batch Execution Performance
Why is Batch Processing faster?
It all boils down to completeness & latency.
Stream Processing Batch Processing
Data is incomplete Data is complete
Latency SLAs No Latency SLAs
Batch Execution vs Stream Execution
Batch Execution vs Stream Execution
Data Exchange Mode
Batch Execution vs Stream Execution
Data Exchange Mode
Batch Execution vs Stream Execution
Data Exchange Mode
Batch Execution vs Stream Execution
Data Exchange Mode
Batch Execution vs Stream Execution
Data Exchange Mode
Batch Execution vs Stream Execution
Fault Tolerance
Stream Processing
Batch Execution vs Stream Execution
Fault Tolerance
Object Store (S3, GCS, HDFS, …)
Periodic Snapshots
Stream Processing
Checkpointing
Batch Execution vs Stream Execution
Fault Tolerance
Object Store (S3, GCS, HDFS, …)
Periodic Snapshots
Stream Processing
Checkpointing
Batch Processing
Batch Execution vs Stream Execution
Fault Tolerance
Object Store (S3, GCS, HDFS, …)
Periodic Snapshots
Stream Processing
Checkpointing
Batch Processing
Batch Execution vs Stream Execution
Fault Tolerance
Object Store (S3, GCS, HDFS, …)
Periodic Snapshots
Stream Processing
Checkpointing
Batch Processing
Batch Execution vs Stream Execution
Fault Tolerance
Object Store (S3, GCS, HDFS, …)
Periodic Snapshots
Stream Processing
Checkpointing
Batch Processing
Backtracking
Local Disk or
External Shuffle Service
Batch Execution vs Stream Execution
Processing Order and State Backends
0
0
Stream Processing
Batch Execution vs Stream Execution
Processing Order and State
0
1
Stream Processing
Batch Execution vs Stream Execution
Processing Order and State
1
1
Stream Processing
Batch Execution vs Stream Execution
Processing Order and State
1
2
Stream Processing
Batch Execution vs Stream Execution
Processing Order and State
2
2
Stream Processing
Batch Execution vs Stream Execution
Processing Order and State
Stream Processing
Keys are processed simultaneously.
2
2
Batch Execution vs Stream Execution
Processing Order and State
2
2
Batch Processing
Stream Processing
Keys are processed simultaneously.
Batch Execution vs Stream Execution
Processing Order and State
2
5
Stream Processing
Keys are processed simultaneously.
Batch Processing
Batch Execution vs Stream Execution
Processing Order and State
2
2
5
Stream Processing
Keys are processed simultaneously.
Batch Processing
Batch Execution vs Stream Execution
Processing Order and State
2
2
6
5
Stream Processing
Keys are processed simultaneously.
Batch Processing
Batch Execution vs Stream Execution
Processing Order and State
2
2
5
6
Stream Processing
Keys are processed simultaneously.
Batch Processing
Batch Execution vs Stream Execution
Processing Order and State
2
2
5
6
Stream Processing
Keys are processed simultaneously.
Batch Processing
Keys are processed one after another.
Batch Execution vs Stream Execution
Time
● Does Processing Time make sense when processing historical data?
○ Not really.
○ All processing time timers fire at the end of the input.
Batch Execution vs Stream Execution
Time
● Does Processing Time make sense when processing historical data?
○ Not really.
○ All processing time timers fire at the end of the input.
● Does historical data arrive out-of-order?
○ No, as it is complete we can sort it by timestamp if needed.
Batch Execution vs Stream Execution
Time
● Does Processing Time make sense when processing historical data?
○ Not really.
○ All processing time timers fire at the end of the input.
● Does historical data arrive out-of-order?
○ No, as it is complete we can sort it by timestamp if needed.
● Do watermarks make sense in batch processing?
○ No, we don’t need them. There is no trade off between latency and completeness.
○ Watermark jumps from -∞ to +∞. All event time timers fire at the end of the input.
Batch Execution vs Stream Execution
Summary
Stream Processing Batch Processing
Data Exchange Mode Pipelined Blocking
Fault Tolerance Checkpointing Backtracking
Processing Order All keys simultaneously Keys one by one
Time
● Event processed out-of-order
● Event and Processing Time
● Watermarks
● Events processed by event time for each key
● Only Eventtime
● No Watermarks
Scenario
We want to reprocess a fixed amount of (recent) historical data to correct a bug or outage.
Wishlist
● Code-reuse for backfilling CHECK
● Same semantics and complete & correct results CHECK
● Resource efficient CHECK (Potential Caveat: Resource Consumption? See Uber Talk.)
Evaluation
Batch Execution Mode
Bootstrapping
79
Scenario
We want to process historical data (weeks, months, year) to build up the applications state
before switching the application to real-time data.
Wishlist
● Code-reuse for bootstrapping
● Different data source for bootstrapping
● Resource efficient
Scenario
[1] https://www.youtube.com/watch?v=BTWntKy_MJs
[2] https://www.youtube.com/watch?v=JQyfXEQqKeg
[3] https://www.youtube.com/watch?v=JKndMiXphzw
1
2
3
Bootstrapping with the Hybrid Source
Hybrid Source automates switching of sources from historical data to real-time
data within a single streaming Job.
S3
Kafka
hours retention
years retention
S3
Bootstrapping with the Hybrid Source
Hybrid Source automates switching of sources from historical data to real-time
data within a single streaming Job.
S3
Kafka
hours retention
years retention
Unbounded Source
Bounded Source
S3
Bootstrapping with the Hybrid Source
Hybrid Source automates switching of sources from historical data to real-time
data within a single streaming Job.
S3
Kafka
hours retention
years retention
S3
All the elasticity and robustness improvements for processing under backpressure apply to here, too.
Bootstrapping with the Hybrid Source
Hybrid Source automates switching of sources from historical data to real-time
data within a single streaming Job.
S3
Kafka
hours retention
years retention
End of Input Reached
S3
Bootstrapping with the Hybrid Source
Hybrid Source automates switching of sources from historical data to real-time
data within a single streaming Job.
S3
Kafka
hours retention
years retention
S3
Bootstrapping with the Hybrid Source
Bootstrapping with the Hybrid Source
Scenario
We want to process historical data (weeks, months, year) to build up the applications state
before switching the application to real-time data.
Wishlist
● Code-reuse for bootstrapping 🗸
● Different data source for bootstrapping 🗸
● Resource efficient
Evaluation
Bootstrapping with Hybrid Source
Bootstrapping with Batch Execution
/dev/null
Bootstrapping Job
With Batch Execution
Separate Data Source Discarding Sink
S3
Bootstrapping with Batch Execution
Savepoint
/dev/null
Bootstrapping Job
With Batch Execution
Separate Data Source Discarding Sink
produces a final Savepoint
S3
Bootstrapping with Batch Execution
Savepoint
/dev/null
Bootstrapping Job
With Batch Execution
Separate Data Source Discarding Sink
Real-Time Job
With Stream Execution
produces a final Savepoint takes a final Savepoint as initial state
S3
Pre-Release!
Demo
Demo
Final Savepoints for Batch Jobs
Next Steps
1. Still some limitations & open questions to address in prototype
2. Publish FLIP & discuss with the Community
3. We are optimistic about Flink 1.17.
Scenario
We want to process historical data (weeks, months, year) to build up the applications state
before switching the application to real-time data.
Wishlist
● Code-reuse for bootstrapping CHECK
● Different data source for bootstrapping CHECK
● Resource efficient CHECK
Evaluation
Bootstrapping with Batch Execution
Takeaways
96
Takeaways
● Just because you are streaming, doesn’t mean you can always avoid processing lots of
data at once
Takeaways
● Just because you are streaming, doesn’t mean you can always avoid processing lots of
data at once
● Batch processing techniques are usually more resource efficient for this.
Takeaways
● Just because you are streaming, doesn’t mean you can always avoid processing lots of
data at once
● Batch processing techniques are usually more resource efficient for this.
● Apache Flink has done a lot recently to make sure those two processing modes work well
together in real-world applications.
Takeaways
● Just because you are streaming, doesn’t mean you doesn’t mean you can always avoid
processing lots of data at once
● Batch processing techniques are usually more resource efficient for this.
● Apache Flink has done a lot recently to make sure those two processing modes work well
together in real-world applications.
● Final Savepoints for Batch Jobs is the last mile for Batch Execution in DataStream API.
Thanks
Konstantin Knauf
@snntrable
konstantin@immerok.io
CDC Stream Processing with
Apache Flink
Timo Walther, 2pm, Ballroom G

More Related Content

PPTX
2018-04 Kafka Summit London: Stephan Ewen - "Apache Flink and Apache Kafka fo...
PPTX
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
PDF
State Management in Apache Flink : Consistent Stateful Distributed Stream Pro...
PDF
Zurich Flink Meetup
PDF
Tzu-Li (Gordon) Tai - Stateful Stream Processing with Apache Flink
PDF
Apache Flink: Better, Faster & Uncut - Piotr Nowojski, data Artisans
PDF
Flink Forward San Francisco 2018: Stefan Richter - "How to build a modern str...
PPTX
GOTO Night Amsterdam - Stream processing with Apache Flink
2018-04 Kafka Summit London: Stephan Ewen - "Apache Flink and Apache Kafka fo...
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
State Management in Apache Flink : Consistent Stateful Distributed Stream Pro...
Zurich Flink Meetup
Tzu-Li (Gordon) Tai - Stateful Stream Processing with Apache Flink
Apache Flink: Better, Faster & Uncut - Piotr Nowojski, data Artisans
Flink Forward San Francisco 2018: Stefan Richter - "How to build a modern str...
GOTO Night Amsterdam - Stream processing with Apache Flink

Similar to When Streaming Needs Batch With Konstantin Knauf | Current 2022 (20)

PDF
Stream Processing with Apache Flink (Flink.tw Meetup 2016/07/19)
PPTX
QCon London - Stream Processing with Apache Flink
PDF
Flink Forward SF 2017: Stephan Ewen - Experiences running Flink at Very Large...
PDF
Introduction to Stateful Stream Processing with Apache Flink.
PPTX
Building Stream Processing as a Service
PDF
Flink Forward Berlin 2018: Steven Wu - "Failure is not fatal: what is your re...
PDF
Getting Data In and Out of Flink - Understanding Flink and Its Connector Ecos...
PDF
Unbounded bounded-data-strangeloop-2016-monal-daxini
PDF
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
PDF
Flink at netflix paypal speaker series
PDF
Not Less, Not More: Exactly Once, Large-Scale Stream Processing in Action
PDF
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
PPTX
Building real time Data Pipeline using Spark Streaming
PDF
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
PPTX
Apache Flink(tm) - A Next-Generation Stream Processor
PDF
Unlocking the Power of Apache Flink: An Introduction in 4 Acts
PPTX
Where is my bottleneck? Performance troubleshooting in Flink
PDF
Tech Talk @ Google on Flink Fault Tolerance and HA
PPTX
Counting Elements in Streams
PDF
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Stream Processing with Apache Flink (Flink.tw Meetup 2016/07/19)
QCon London - Stream Processing with Apache Flink
Flink Forward SF 2017: Stephan Ewen - Experiences running Flink at Very Large...
Introduction to Stateful Stream Processing with Apache Flink.
Building Stream Processing as a Service
Flink Forward Berlin 2018: Steven Wu - "Failure is not fatal: what is your re...
Getting Data In and Out of Flink - Understanding Flink and Its Connector Ecos...
Unbounded bounded-data-strangeloop-2016-monal-daxini
Flink Forward SF 2017: Kenneth Knowles - Back to Sessions overview
Flink at netflix paypal speaker series
Not Less, Not More: Exactly Once, Large-Scale Stream Processing in Action
ApacheCon 2020 - Flink SQL in 2020: Time to show off!
Building real time Data Pipeline using Spark Streaming
Analyzing Petabyte Scale Financial Data with Apache Pinot and Apache Kafka | ...
Apache Flink(tm) - A Next-Generation Stream Processor
Unlocking the Power of Apache Flink: An Introduction in 4 Acts
Where is my bottleneck? Performance troubleshooting in Flink
Tech Talk @ Google on Flink Fault Tolerance and HA
Counting Elements in Streams
Keynote: Building and Operating A Serverless Streaming Runtime for Apache Bea...
Ad

More from HostedbyConfluent (20)

PDF
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
PDF
Renaming a Kafka Topic | Kafka Summit London
PDF
Evolution of NRT Data Ingestion Pipeline at Trendyol
PDF
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
PDF
Exactly-once Stream Processing with Arroyo and Kafka
PDF
Fish Plays Pokemon | Kafka Summit London
PDF
Tiered Storage 101 | Kafla Summit London
PDF
Building a Self-Service Stream Processing Portal: How And Why
PDF
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
PDF
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
PDF
Navigating Private Network Connectivity Options for Kafka Clusters
PDF
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
PDF
Explaining How Real-Time GenAI Works in a Noisy Pub
PDF
TL;DR Kafka Metrics | Kafka Summit London
PDF
A Window Into Your Kafka Streams Tasks | KSL
PDF
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
PDF
Data Contracts Management: Schema Registry and Beyond
PDF
Code-First Approach: Crafting Efficient Flink Apps
PDF
Debezium vs. the World: An Overview of the CDC Ecosystem
PDF
Beyond Tiered Storage: Serverless Kafka with No Local Disks
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Renaming a Kafka Topic | Kafka Summit London
Evolution of NRT Data Ingestion Pipeline at Trendyol
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Exactly-once Stream Processing with Arroyo and Kafka
Fish Plays Pokemon | Kafka Summit London
Tiered Storage 101 | Kafla Summit London
Building a Self-Service Stream Processing Portal: How And Why
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Navigating Private Network Connectivity Options for Kafka Clusters
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
Explaining How Real-Time GenAI Works in a Noisy Pub
TL;DR Kafka Metrics | Kafka Summit London
A Window Into Your Kafka Streams Tasks | KSL
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
Data Contracts Management: Schema Registry and Beyond
Code-First Approach: Crafting Efficient Flink Apps
Debezium vs. the World: An Overview of the CDC Ecosystem
Beyond Tiered Storage: Serverless Kafka with No Local Disks
Ad

Recently uploaded (20)

PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Modernizing your data center with Dell and AMD
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Encapsulation theory and applications.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Cloud computing and distributed systems.
PDF
Review of recent advances in non-invasive hemoglobin estimation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
Modernizing your data center with Dell and AMD
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Reach Out and Touch Someone: Haptics and Empathic Computing
Building Integrated photovoltaic BIPV_UPV.pdf
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Encapsulation theory and applications.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
NewMind AI Weekly Chronicles - August'25 Week I
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Cloud computing and distributed systems.
Review of recent advances in non-invasive hemoglobin estimation

When Streaming Needs Batch With Konstantin Knauf | Current 2022

  • 1. When Streaming Needs Batch - Flink's Journey Towards a Unified Engine Konstantin Knauf – @snntrable – Current 22
  • 2. About Me 2 ● Co-Founder @ Immerok ● Apache Flink Committer & Member of the PMC ● Formerly Head of Product & Field Engineer @ Ververica Visit us at booth S14.
  • 3. Steady State - Streaming Heaven 3
  • 4. 4
  • 6. Backfilling or after an introducing a bug
  • 10. Agenda Motivation CHECK Setting the Stage Catching Up & Handling Bursty Streams Backfilling Bootstrapping Takeaways
  • 12. Stream Processing Batch Processing Bounded Data CHECK CHECK Unbounded Data CHECK Some Terminology Nature of Data Nature of Processing
  • 13. A Typical Streaming Job Apache Kafka* in/out * or any other replayable queue like Apache Pulsar/AWS Kinesis/…
  • 14. A Typical Streaming Job Flink Pipeline with multiple operators & shuffles
  • 15. A Typical Streaming Job incl. significant state
  • 20. Catching Up & Bursty Streams 20
  • 21. Scenario There is a large backlog of data and you want to catch up to real-time again. For example, happens when upstream producers send data in big chunks. Wishlist ● process backlog quickly ● process backlog robustly with existing resources Scenario 1
  • 22. Backlog -> Backpressure When under backpressure, what do you want? ● Scale up ● Or catch up steadily
  • 23. Backlog -> Backpressure When under backpressure, what do you want? ● Scale up ● Or catch up steadily
  • 24. Scaling Up under Backpressure Adaptive Scheduler and Reactive Mode (Flink 1.13) Task Manager Task Slot Task Slot
  • 25. Scaling Up under Backpressure Adaptive Scheduler and Reactive Mode (Flink 1.13) Task Manager Task Slot Task Slot Task Manager Task Slot Task Slot
  • 26. Scaling Up under Backpressure Adaptive Scheduler and Reactive Mode (Flink 1.13) Task Manager Task Slot Task Slot Task Manager Task Slot Task Slot ● Job automatically scales up when provided with additional resources ● No additional Savepoint needed for rescaling* * Caveat: This might still take quite some time during restore. Flink 1.16 brings some more improvements in that regard.
  • 27. Backlog -> Backpressure When under backpressure, what do you want? ● Scale up ● Or catch up steadily
  • 28. Robustness under Backpressure Watermark Alignment (Flink 1.15) high throughput topic low throughput topic
  • 29. Robustness under Backpressure Watermark Alignment (Flink 1.15) advances watermark ~ with processing time advances watermark ~ with processing time
  • 30. Robustness under Backpressure Watermark Alignment (Flink 1.15) advances watermark slowly advances watermark very quickly
  • 31. Robustness under Backpressure Watermark Alignment (Flink 1.15) join state grows during processing a backlog
  • 32. Robustness under Backpressure Watermark Alignment (Flink 1.15) advances watermark slowly advances watermark very quickly
  • 33. Robustness under Backpressure Unaligned Checkpoints (Flink 1.11-1.13) & Buffer Debloating (Flink 1.14) checkpoint barrier n 6 x 5 4 3 2 1 f e c d b a h g e f d c y 9 8 7 6 5 4 a y b 1 2 3 input buffer aligning begin aligning operator operator
  • 34. Robustness under Backpressure Unaligned Checkpoints (Flink 1.11-1.13) & Buffer Debloating (Flink 1.14) Under backpressure & at scale checkpoint alignment can take hours leading to checkpoint timeouts and job failures. ● Buffer debloating dramatically reduces the amount of in-flight data ● Unaligned checkpoints allows barriers to overtake in-flight data checkpoint barrier n 6 x 5 4 3 2 1 f e c d b a h g e f d c y 9 8 7 6 5 4 a y b 1 2 3 input buffer aligning begin aligning operator operator
  • 35. Scenario There is a large backlog of data and you want to catch up to real-time again. For example, happens when upstream producers send data in big chunks. Wishlist ● process backlog quickly CHECK (Adaptive Scheduler) ● process backlog robustly with existing resources CHECK (Buffer Debloating, Watermark Alignment, Unaligned Checkpoints) Scenario
  • 37. Scenario You want to reprocess a fixed amount of (recent) historical data to correct a bug or outage. Wishlist ● Code-reuse for backfilling ● Same semantics and complete & correct results ● Resource efficient Scenario [1] https://www.youtube.com/watch?v=4qSlsYogALo&t=668s 1
  • 38. 38 - The Apache Flink Community Batch is a Special Case of Streaming
  • 41. DataStream API with Streaming Execution All the elasticity and robustness improvements for processing under backpressure apply to here, too.
  • 42. Scenario We want to reprocess a fixed amount of (recent) historical data to correct a bug or outage. Wishlist ● Code-reuse for backfilling CHECK ● Same semantics and complete & correct results CHECK ● Resource efficient Evaluation Stream Execution Mode
  • 43. Batch Execution Mode Implementation Timeline ● Apache Flink 1.12 ○ Initial Release ○ Unified Sink API (beta) ● Apache Flink 1.13 ○ Support for Python DataStream API ● Apache Flink 1.14 ○ Batch Execution Mode for mixed DataStream/Table API programs ○ Unified Sink API stable ○ Unified Source API stable ● Apache Flink 1.15 ○ Most Sources/Sinks migrated to unified interfaces ○ Adaptive Batch Scheduler
  • 48. Why is Batch Processing faster?
  • 49. It all boils down to completeness & latency. Stream Processing Batch Processing Data is incomplete Data is complete Latency SLAs No Latency SLAs
  • 50. Batch Execution vs Stream Execution
  • 51. Batch Execution vs Stream Execution Data Exchange Mode
  • 52. Batch Execution vs Stream Execution Data Exchange Mode
  • 53. Batch Execution vs Stream Execution Data Exchange Mode
  • 54. Batch Execution vs Stream Execution Data Exchange Mode
  • 55. Batch Execution vs Stream Execution Data Exchange Mode
  • 56. Batch Execution vs Stream Execution Fault Tolerance Stream Processing
  • 57. Batch Execution vs Stream Execution Fault Tolerance Object Store (S3, GCS, HDFS, …) Periodic Snapshots Stream Processing Checkpointing
  • 58. Batch Execution vs Stream Execution Fault Tolerance Object Store (S3, GCS, HDFS, …) Periodic Snapshots Stream Processing Checkpointing Batch Processing
  • 59. Batch Execution vs Stream Execution Fault Tolerance Object Store (S3, GCS, HDFS, …) Periodic Snapshots Stream Processing Checkpointing Batch Processing
  • 60. Batch Execution vs Stream Execution Fault Tolerance Object Store (S3, GCS, HDFS, …) Periodic Snapshots Stream Processing Checkpointing Batch Processing
  • 61. Batch Execution vs Stream Execution Fault Tolerance Object Store (S3, GCS, HDFS, …) Periodic Snapshots Stream Processing Checkpointing Batch Processing Backtracking Local Disk or External Shuffle Service
  • 62. Batch Execution vs Stream Execution Processing Order and State Backends 0 0 Stream Processing
  • 63. Batch Execution vs Stream Execution Processing Order and State 0 1 Stream Processing
  • 64. Batch Execution vs Stream Execution Processing Order and State 1 1 Stream Processing
  • 65. Batch Execution vs Stream Execution Processing Order and State 1 2 Stream Processing
  • 66. Batch Execution vs Stream Execution Processing Order and State 2 2 Stream Processing
  • 67. Batch Execution vs Stream Execution Processing Order and State Stream Processing Keys are processed simultaneously. 2 2
  • 68. Batch Execution vs Stream Execution Processing Order and State 2 2 Batch Processing Stream Processing Keys are processed simultaneously.
  • 69. Batch Execution vs Stream Execution Processing Order and State 2 5 Stream Processing Keys are processed simultaneously. Batch Processing
  • 70. Batch Execution vs Stream Execution Processing Order and State 2 2 5 Stream Processing Keys are processed simultaneously. Batch Processing
  • 71. Batch Execution vs Stream Execution Processing Order and State 2 2 6 5 Stream Processing Keys are processed simultaneously. Batch Processing
  • 72. Batch Execution vs Stream Execution Processing Order and State 2 2 5 6 Stream Processing Keys are processed simultaneously. Batch Processing
  • 73. Batch Execution vs Stream Execution Processing Order and State 2 2 5 6 Stream Processing Keys are processed simultaneously. Batch Processing Keys are processed one after another.
  • 74. Batch Execution vs Stream Execution Time ● Does Processing Time make sense when processing historical data? ○ Not really. ○ All processing time timers fire at the end of the input.
  • 75. Batch Execution vs Stream Execution Time ● Does Processing Time make sense when processing historical data? ○ Not really. ○ All processing time timers fire at the end of the input. ● Does historical data arrive out-of-order? ○ No, as it is complete we can sort it by timestamp if needed.
  • 76. Batch Execution vs Stream Execution Time ● Does Processing Time make sense when processing historical data? ○ Not really. ○ All processing time timers fire at the end of the input. ● Does historical data arrive out-of-order? ○ No, as it is complete we can sort it by timestamp if needed. ● Do watermarks make sense in batch processing? ○ No, we don’t need them. There is no trade off between latency and completeness. ○ Watermark jumps from -∞ to +∞. All event time timers fire at the end of the input.
  • 77. Batch Execution vs Stream Execution Summary Stream Processing Batch Processing Data Exchange Mode Pipelined Blocking Fault Tolerance Checkpointing Backtracking Processing Order All keys simultaneously Keys one by one Time ● Event processed out-of-order ● Event and Processing Time ● Watermarks ● Events processed by event time for each key ● Only Eventtime ● No Watermarks
  • 78. Scenario We want to reprocess a fixed amount of (recent) historical data to correct a bug or outage. Wishlist ● Code-reuse for backfilling CHECK ● Same semantics and complete & correct results CHECK ● Resource efficient CHECK (Potential Caveat: Resource Consumption? See Uber Talk.) Evaluation Batch Execution Mode
  • 80. Scenario We want to process historical data (weeks, months, year) to build up the applications state before switching the application to real-time data. Wishlist ● Code-reuse for bootstrapping ● Different data source for bootstrapping ● Resource efficient Scenario [1] https://www.youtube.com/watch?v=BTWntKy_MJs [2] https://www.youtube.com/watch?v=JQyfXEQqKeg [3] https://www.youtube.com/watch?v=JKndMiXphzw 1 2 3
  • 81. Bootstrapping with the Hybrid Source Hybrid Source automates switching of sources from historical data to real-time data within a single streaming Job. S3 Kafka hours retention years retention S3
  • 82. Bootstrapping with the Hybrid Source Hybrid Source automates switching of sources from historical data to real-time data within a single streaming Job. S3 Kafka hours retention years retention Unbounded Source Bounded Source S3
  • 83. Bootstrapping with the Hybrid Source Hybrid Source automates switching of sources from historical data to real-time data within a single streaming Job. S3 Kafka hours retention years retention S3 All the elasticity and robustness improvements for processing under backpressure apply to here, too.
  • 84. Bootstrapping with the Hybrid Source Hybrid Source automates switching of sources from historical data to real-time data within a single streaming Job. S3 Kafka hours retention years retention End of Input Reached S3
  • 85. Bootstrapping with the Hybrid Source Hybrid Source automates switching of sources from historical data to real-time data within a single streaming Job. S3 Kafka hours retention years retention S3
  • 86. Bootstrapping with the Hybrid Source
  • 87. Bootstrapping with the Hybrid Source
  • 88. Scenario We want to process historical data (weeks, months, year) to build up the applications state before switching the application to real-time data. Wishlist ● Code-reuse for bootstrapping 🗸 ● Different data source for bootstrapping 🗸 ● Resource efficient Evaluation Bootstrapping with Hybrid Source
  • 89. Bootstrapping with Batch Execution /dev/null Bootstrapping Job With Batch Execution Separate Data Source Discarding Sink S3
  • 90. Bootstrapping with Batch Execution Savepoint /dev/null Bootstrapping Job With Batch Execution Separate Data Source Discarding Sink produces a final Savepoint S3
  • 91. Bootstrapping with Batch Execution Savepoint /dev/null Bootstrapping Job With Batch Execution Separate Data Source Discarding Sink Real-Time Job With Stream Execution produces a final Savepoint takes a final Savepoint as initial state S3 Pre-Release!
  • 92. Demo
  • 93. Demo
  • 94. Final Savepoints for Batch Jobs Next Steps 1. Still some limitations & open questions to address in prototype 2. Publish FLIP & discuss with the Community 3. We are optimistic about Flink 1.17.
  • 95. Scenario We want to process historical data (weeks, months, year) to build up the applications state before switching the application to real-time data. Wishlist ● Code-reuse for bootstrapping CHECK ● Different data source for bootstrapping CHECK ● Resource efficient CHECK Evaluation Bootstrapping with Batch Execution
  • 97. Takeaways ● Just because you are streaming, doesn’t mean you can always avoid processing lots of data at once
  • 98. Takeaways ● Just because you are streaming, doesn’t mean you can always avoid processing lots of data at once ● Batch processing techniques are usually more resource efficient for this.
  • 99. Takeaways ● Just because you are streaming, doesn’t mean you can always avoid processing lots of data at once ● Batch processing techniques are usually more resource efficient for this. ● Apache Flink has done a lot recently to make sure those two processing modes work well together in real-world applications.
  • 100. Takeaways ● Just because you are streaming, doesn’t mean you doesn’t mean you can always avoid processing lots of data at once ● Batch processing techniques are usually more resource efficient for this. ● Apache Flink has done a lot recently to make sure those two processing modes work well together in real-world applications. ● Final Savepoints for Batch Jobs is the last mile for Batch Execution in DataStream API.
  • 101. Thanks Konstantin Knauf @snntrable konstantin@immerok.io CDC Stream Processing with Apache Flink Timo Walther, 2pm, Ballroom G