SlideShare a Scribd company logo
Exactly-Once End-To-End Processing with
Apache Apex
55th Bay Area Hadoop User Group (HUG) Meetup
February 15, 2017
Vlad Rozov
Apache Apex PMC
vrozov@apache.org
http://github.com/vrozov
Engineer at DataTorrent
v.rozov@datatorrent.com
CoD fan
About me
http://www.apexbigdata.com
Computer History Museum
April 4, 2017
Apex Big Data World - San Jose
Apache Apex Platform Features
• In-memory, distributed stream processing
ᵒ Application logic broken into components (operators) that execute distributed in a
cluster
ᵒ Unobtrusive Java API to express (custom) logic
ᵒ Maintain state and metrics in member variables
ᵒ Windowing, event-time processing
• Scalable, high throughput, low latency
ᵒ Operators can be scaled up or down at runtime according to the load and SLA
ᵒ Dynamic scaling (elasticity), compute locality
• Fault tolerance & correctness
ᵒ Automatically recover from node outages without having to reprocess from
beginning
ᵒ State is preserved, checkpointing, incremental recovery
ᵒ End-to-end exactly-once
• Operability
ᵒ System and application metrics, record/visualize data
ᵒ Dynamic changes and resource allocation, elasticity
Apache Apex Platform Overview
Fault Tolerance
• Operator state is checkpointed to persistent store
ᵒ Automatically performed by engine, no additional coding needed
ᵒ Asynchronous and distributed
ᵒ In case of failure operators are restarted from checkpoint state
• Automatic detection and recovery of failed containers
ᵒ Heartbeat mechanism
ᵒ YARN process status notification
• Buffering to enable replay of data from recovered point
ᵒ Fast, incremental recovery, spike handling
• Application master state checkpointed
ᵒ Snapshot of physical (and logical) plan
ᵒ Execution layer change log
Checkpointing Operator State
• Save state of operator so that it can be recovered on failure
• Pluggable storage handler
• Default implementation
ᵒ Serialization with Kryo
ᵒ All non-transient fields serialized
ᵒ Serialized state written to HDFS
ᵒ Writes asynchronous, non-blocking
• Possible to implement custom handlers for alternative approach to extract state or
different storage backend (such as IMDG)
• For operators that rely on previous state for computation operators can be marked
@Stateless to skip checkpointing
• Checkpoint frequency tunable (by default 30s)
ᵒ Based on streaming windows for consistent state
Sample Failure Scenario
… EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1
sum
0
… EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1
sum
7
… EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1
… EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1
sum
7
sum
10
At most once At least once Exactly once
Subscribes to data from the
start of the next window.
Operator brought back to its
latest checkpointed state and
the upstream buffer server
replays all subsequent windows
Operator brought back to its
latest checkpointed state and
the upstream buffer server
replays all subsequent
windows
Ignore the lost windows and
continue to process incoming
data normally.
Lost windows are recomputed &
application catches up live
incoming data
Lost windows are recomputed
in a logical way to have the
effect as if computation has
been done exactly once.
No duplicates & no
recomputation
Likely duplicates &
recomputation
No duplicates &
recomputation?
Possible missing data No lost data No lost data
Processing Guarantees
End-to-End Exactly Once
• Becomes important when writing to external systems
• Data should not be duplicated or lost in the external system even in case of
application failures
• Common external systems
ᵒ Databases
ᵒ Files
ᵒ Message queues
• Platform support for at least once is a must so that no data is lost
• Data duplication must still be avoided when data is replayed from checkpoint
ᵒ Operators implement the logic dependent on the external system
• Aid of platform features such as stateful checkpointing and windowing
• Three different mechanisms with implementations explained in next slides
Files
Streaming data is being written to file on a continuous basis
Failure at a random point results in file with an unknown amount of data
Operator works with platform to ensure exactly once
• Platform responsibility
ᵒ Restores state and restarts operator from an earlier checkpoint
ᵒ Platform replays data from the exact point after checkpoint
• Operator responsibility
ᵒ Replayed data doesn’t get duplicated in the file
ᵒ Accomplishes by keeping track of file offset as state
Existing implementation from Malhar Library AbstractFileOutputOperator.java
Exactly Once Strategy
File Data
Offset
Ensures no data is duplicated or lost
Chk
Operator saves file offset during checkpoint
File contents are flushed before checkpoint
to ensure there is no pending data in buffer
On recovery platform restores the file offset
value from checkpoint
Operator truncates the file to the offset
Starts writing data again
Transactional databases
13
Use of streaming windows
For exactly once in failure scenarios
• Operator uses transactions
• Stores window id in a separate table in the database
Existing implementation from Malhar Library
AbstractJdbcTransactionableOutputOperator.java
Exactly Once Strategy
d11 d12 d13
d21 d22 d23
lwn1 lwn2 lwn3
op-id wn
chk wn wn+1
Lwn+11 Lwn+12 Lwn+13
op-id wn+1
Data Table
Meta Table
Data in a window is written out in a single transaction
Window id is also written to a meta table as part of
the same transaction
Operator reads the window id from meta table on
recovery
Ignores data for windows less than the recovered
window id and writes new data
Partial window data before failure will not appear in
data table as transaction was not committed
Assumes idempotency for replay
Stateful Message Queue
15
Data is being sent to a stateful message queue like Apache Kafka
On failure data already sent to message queue should not be re-sent
Exactly once strategy
• Sends a key along with data that is monotonically increasing
• On recovery operator asks the message queue for the last sent message
• Gets the recovery key from the message
• Ignores all replayed data with key that is less than or equal to the recovered key
• If the key is not monotonically increasing then data can be sorted on the key at the
end of the window and sent to message queue
Existing implementation from Malhar Library:
AbstractExactlyOnceKafkaOutputOperator.java
Resources
Apache Apex - http://apex.apache.org/
Subscribe to forums
Apex - http://apex.apache.org/community.html
DataTorrent - https://groups.google.com/forum/#!forum/dt-users
Download - https://datatorrent.com/download/
Twitter
@ApacheApex; Follow - https://twitter.com/apacheapex
@DataTorrent; Follow - https://twitter.com/datatorrent
Meetups - http://meetup.com/topics/apache-apex
Webinars - https://datatorrent.com/webinars/
Videos - https://youtube.com/user/DataTorrent
Slides - http://slideshare.net/DataTorrent/presentations
Startup Accelerator - Free full featured enterprise product
https://datatorrent.com/product/startup-accelerator/
Big Data Application Templates Hub - https://datatorrent.com/apphub
Questions?

More Related Content

What's hot (20)

PPTX
Fault-Tolerant File Input & Output
Apache Apex
 
PPTX
Stream Processing with Apache Apex
Pramod Immaneni
 
PPTX
Architectual Comparison of Apache Apex and Spark Streaming
Apache Apex
 
PPTX
Apache Apex: Stream Processing Architecture and Applications
Thomas Weise
 
PPTX
Introduction to Apache Apex
Apache Apex
 
PPTX
Hadoop Summit SJ 2016: Next Gen Big Data Analytics with Apache Apex
Apache Apex
 
PPTX
Smart Partitioning with Apache Apex (Webinar)
Apache Apex
 
PPTX
Apache Apex Meetup at Cask
Apache Apex
 
PPTX
Intro to Apache Apex @ Women in Big Data
Apache Apex
 
PDF
Introduction to Apache Apex - CoDS 2016
Bhupesh Chawda
 
PPTX
Ingesting Data from Kafka to JDBC with Transformation and Enrichment
Apache Apex
 
PPTX
Next-Gen Decision Making in Under 2ms
Ilya Ganelin
 
PDF
Apache Big Data EU 2016: Next Gen Big Data Analytics with Apache Apex
Apache Apex
 
PDF
Developing streaming applications with apache apex (strata + hadoop world)
Apache Apex
 
PDF
Apex as yarn application
Chinmay Kolhatkar
 
PPTX
DataTorrent Presentation @ Big Data Application Meetup
Thomas Weise
 
PDF
Low Latency Polyglot Model Scoring using Apache Apex
Apache Apex
 
PPTX
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Apache Apex
 
PPTX
Fault tolerance
Thisara Pramuditha
 
PDF
From Batch to Streaming with Apache Apex Dataworks Summit 2017
Apache Apex
 
Fault-Tolerant File Input & Output
Apache Apex
 
Stream Processing with Apache Apex
Pramod Immaneni
 
Architectual Comparison of Apache Apex and Spark Streaming
Apache Apex
 
Apache Apex: Stream Processing Architecture and Applications
Thomas Weise
 
Introduction to Apache Apex
Apache Apex
 
Hadoop Summit SJ 2016: Next Gen Big Data Analytics with Apache Apex
Apache Apex
 
Smart Partitioning with Apache Apex (Webinar)
Apache Apex
 
Apache Apex Meetup at Cask
Apache Apex
 
Intro to Apache Apex @ Women in Big Data
Apache Apex
 
Introduction to Apache Apex - CoDS 2016
Bhupesh Chawda
 
Ingesting Data from Kafka to JDBC with Transformation and Enrichment
Apache Apex
 
Next-Gen Decision Making in Under 2ms
Ilya Ganelin
 
Apache Big Data EU 2016: Next Gen Big Data Analytics with Apache Apex
Apache Apex
 
Developing streaming applications with apache apex (strata + hadoop world)
Apache Apex
 
Apex as yarn application
Chinmay Kolhatkar
 
DataTorrent Presentation @ Big Data Application Meetup
Thomas Weise
 
Low Latency Polyglot Model Scoring using Apache Apex
Apache Apex
 
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Apache Apex
 
Fault tolerance
Thisara Pramuditha
 
From Batch to Streaming with Apache Apex Dataworks Summit 2017
Apache Apex
 

Viewers also liked (20)

PPTX
February 2017 HUG: Data Sketches: A required toolkit for Big Data Analytics
Yahoo Developer Network
 
PPTX
Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
PPTX
SimplifyStreamingArchitecture
Maheedhar Gunturu
 
PDF
Containerizing Distributed Pipes
inside-BigData.com
 
PDF
Complex Event Processing with Esper
Ted Won
 
PDF
Apex & Geode: In-memory streaming, storage & analytics
Ashish Tadose
 
PDF
Reactive integrations with Akka Streams
Konrad Malawski
 
PDF
Streamsets and spark
Hari Shreedharan
 
PDF
Apache Flink's Table & SQL API - unified APIs for batch and stream processing
Timo Walther
 
PDF
[OracleCode SF] In memory analytics with apache spark and hazelcast
Viktor Gamov
 
PDF
Akka-chan's Survival Guide for the Streaming World
Konrad Malawski
 
PDF
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
Yahoo Developer Network
 
PPTX
October 2016 HUG: Architecture of an Open Source RDBMS powered by HBase and ...
Yahoo Developer Network
 
PPTX
How to Avoid Problems with Lump-sum Relocation Allowances
Parsifal Corporation
 
PDF
Going bananas with recursion schemes for fixed point data types
Pawel Szulc
 
PPT
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Slim Baltagi
 
PPTX
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
PDF
Kappa Architecture, IoT of the cars - LibreCon 2016
LibreCon
 
PDF
Extracting Insights from Data at Twitter
Prasad Wagle
 
PDF
[OracleCode - SF] Distributed caching for your next node.js project
Viktor Gamov
 
February 2017 HUG: Data Sketches: A required toolkit for Big Data Analytics
Yahoo Developer Network
 
Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
SimplifyStreamingArchitecture
Maheedhar Gunturu
 
Containerizing Distributed Pipes
inside-BigData.com
 
Complex Event Processing with Esper
Ted Won
 
Apex & Geode: In-memory streaming, storage & analytics
Ashish Tadose
 
Reactive integrations with Akka Streams
Konrad Malawski
 
Streamsets and spark
Hari Shreedharan
 
Apache Flink's Table & SQL API - unified APIs for batch and stream processing
Timo Walther
 
[OracleCode SF] In memory analytics with apache spark and hazelcast
Viktor Gamov
 
Akka-chan's Survival Guide for the Streaming World
Konrad Malawski
 
October 2016 HUG: Pulsar,  a highly scalable, low latency pub-sub messaging s...
Yahoo Developer Network
 
October 2016 HUG: Architecture of an Open Source RDBMS powered by HBase and ...
Yahoo Developer Network
 
How to Avoid Problems with Lump-sum Relocation Allowances
Parsifal Corporation
 
Going bananas with recursion schemes for fixed point data types
Pawel Szulc
 
Apache Flink Crash Course by Slim Baltagi and Srini Palthepu
Slim Baltagi
 
Building Reactive Fast Data & the Data Lake with Akka, Kafka, Spark
Todd Fritz
 
Kappa Architecture, IoT of the cars - LibreCon 2016
LibreCon
 
Extracting Insights from Data at Twitter
Prasad Wagle
 
[OracleCode - SF] Distributed caching for your next node.js project
Viktor Gamov
 
Ad

Similar to February 2017 HUG: Exactly-once end-to-end processing with Apache Apex (20)

PPTX
Apache Apex Fault Tolerance and Processing Semantics
Apache Apex
 
PPTX
Intro to Apache Apex - Next Gen Native Hadoop Platform - Hackac
Apache Apex
 
PDF
Introduction to Apache Apex by Thomas Weise
Big Data Spain
 
PDF
Stateful streaming data pipelines
Timothy Farkas
 
PPTX
Apache Apex: Stream Processing Architecture and Applications
Comsysto Reply GmbH
 
PDF
BigDataSpain 2016: Introduction to Apache Apex
Thomas Weise
 
PPSX
GE IOT Predix Time Series & Data Ingestion Service using Apache Apex (Hadoop)
Apache Apex
 
PDF
Real-time Stream Processing using Apache Apex
Apache Apex
 
PPTX
Stream data from Apache Kafka for processing with Apache Apex
Apache Apex
 
PDF
Exactly-once Stream Processing Done Right with Matthias J Sax
HostedbyConfluent
 
PPTX
Next Gen Big Data Analytics with Apache Apex
DataWorks Summit/Hadoop Summit
 
PDF
Tech Talk @ Google on Flink Fault Tolerance and HA
Paris Carbone
 
PDF
Reactive mistakes - ScalaDays Chicago 2017
Petr Zapletal
 
PDF
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Apache Apex
 
PPTX
Stream processing - Apache flink
Renato Guimaraes
 
PDF
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
confluent
 
PPTX
data-stream-processing-SEEP.pptx
AhmadTawfigAlRadaide
 
PDF
Open west 2015 talk ben coverston
bcoverston
 
PPTX
Dynamic Resource Management In a Massively Parallel Stream Processing Engine
Kasper Grud Skat Madsen
 
PDF
Predictive Datacenter Analytics with Strymon
Vasia Kalavri
 
Apache Apex Fault Tolerance and Processing Semantics
Apache Apex
 
Intro to Apache Apex - Next Gen Native Hadoop Platform - Hackac
Apache Apex
 
Introduction to Apache Apex by Thomas Weise
Big Data Spain
 
Stateful streaming data pipelines
Timothy Farkas
 
Apache Apex: Stream Processing Architecture and Applications
Comsysto Reply GmbH
 
BigDataSpain 2016: Introduction to Apache Apex
Thomas Weise
 
GE IOT Predix Time Series & Data Ingestion Service using Apache Apex (Hadoop)
Apache Apex
 
Real-time Stream Processing using Apache Apex
Apache Apex
 
Stream data from Apache Kafka for processing with Apache Apex
Apache Apex
 
Exactly-once Stream Processing Done Right with Matthias J Sax
HostedbyConfluent
 
Next Gen Big Data Analytics with Apache Apex
DataWorks Summit/Hadoop Summit
 
Tech Talk @ Google on Flink Fault Tolerance and HA
Paris Carbone
 
Reactive mistakes - ScalaDays Chicago 2017
Petr Zapletal
 
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Apache Apex
 
Stream processing - Apache flink
Renato Guimaraes
 
Hard Truths About Streaming and Eventing (Dan Rosanova, Microsoft) Kafka Summ...
confluent
 
data-stream-processing-SEEP.pptx
AhmadTawfigAlRadaide
 
Open west 2015 talk ben coverston
bcoverston
 
Dynamic Resource Management In a Massively Parallel Stream Processing Engine
Kasper Grud Skat Madsen
 
Predictive Datacenter Analytics with Strymon
Vasia Kalavri
 
Ad

More from Yahoo Developer Network (20)

PDF
Developing Mobile Apps for Performance - Swapnil Patel, Verizon Media
Yahoo Developer Network
 
PDF
Athenz - The Open-Source Solution to Provide Access Control in Dynamic Infras...
Yahoo Developer Network
 
PDF
Athenz & SPIFFE, Tatsuya Yano, Yahoo Japan
Yahoo Developer Network
 
PDF
Athenz with Istio - Single Access Control Model in Cloud Infrastructures, Tat...
Yahoo Developer Network
 
PDF
CICD at Oath using Screwdriver
Yahoo Developer Network
 
PDF
Big Data Serving with Vespa - Jon Bratseth, Distinguished Architect, Oath
Yahoo Developer Network
 
PPTX
How @TwitterHadoop Chose Google Cloud, Joep Rottinghuis, Lohit VijayaRenu
Yahoo Developer Network
 
PDF
The Future of Hadoop in an AI World, Milind Bhandarkar, CEO, Ampool
Yahoo Developer Network
 
PPTX
Apache YARN Federation and Tez at Microsoft, Anupam Upadhyay, Adrian Nicoara,...
Yahoo Developer Network
 
PPTX
Containerized Services on Apache Hadoop YARN: Past, Present, and Future, Shan...
Yahoo Developer Network
 
PDF
HDFS Scalability and Security, Daryn Sharp, Senior Engineer, Oath
Yahoo Developer Network
 
PPTX
Hadoop {Submarine} Project: Running deep learning workloads on YARN, Wangda T...
Yahoo Developer Network
 
PDF
Moving the Oath Grid to Docker, Eric Badger, Oath
Yahoo Developer Network
 
PDF
Architecting Petabyte Scale AI Applications
Yahoo Developer Network
 
PDF
Introduction to Vespa – The Open Source Big Data Serving Engine, Jon Bratseth...
Yahoo Developer Network
 
PPTX
Jun 2017 HUG: YARN Scheduling – A Step Beyond
Yahoo Developer Network
 
PDF
Jun 2017 HUG: Large-Scale Machine Learning: Use Cases and Technologies
Yahoo Developer Network
 
PPTX
October 2016 HUG: The Pillars of Effective Data Archiving and Tiering in Hadoop
Yahoo Developer Network
 
PPTX
August 2016 HUG: Recent development in Apache Oozie
Yahoo Developer Network
 
PDF
August 2016 HUG: Better together: Fast Data with Apache Spark™ and Apache Ign...
Yahoo Developer Network
 
Developing Mobile Apps for Performance - Swapnil Patel, Verizon Media
Yahoo Developer Network
 
Athenz - The Open-Source Solution to Provide Access Control in Dynamic Infras...
Yahoo Developer Network
 
Athenz & SPIFFE, Tatsuya Yano, Yahoo Japan
Yahoo Developer Network
 
Athenz with Istio - Single Access Control Model in Cloud Infrastructures, Tat...
Yahoo Developer Network
 
CICD at Oath using Screwdriver
Yahoo Developer Network
 
Big Data Serving with Vespa - Jon Bratseth, Distinguished Architect, Oath
Yahoo Developer Network
 
How @TwitterHadoop Chose Google Cloud, Joep Rottinghuis, Lohit VijayaRenu
Yahoo Developer Network
 
The Future of Hadoop in an AI World, Milind Bhandarkar, CEO, Ampool
Yahoo Developer Network
 
Apache YARN Federation and Tez at Microsoft, Anupam Upadhyay, Adrian Nicoara,...
Yahoo Developer Network
 
Containerized Services on Apache Hadoop YARN: Past, Present, and Future, Shan...
Yahoo Developer Network
 
HDFS Scalability and Security, Daryn Sharp, Senior Engineer, Oath
Yahoo Developer Network
 
Hadoop {Submarine} Project: Running deep learning workloads on YARN, Wangda T...
Yahoo Developer Network
 
Moving the Oath Grid to Docker, Eric Badger, Oath
Yahoo Developer Network
 
Architecting Petabyte Scale AI Applications
Yahoo Developer Network
 
Introduction to Vespa – The Open Source Big Data Serving Engine, Jon Bratseth...
Yahoo Developer Network
 
Jun 2017 HUG: YARN Scheduling – A Step Beyond
Yahoo Developer Network
 
Jun 2017 HUG: Large-Scale Machine Learning: Use Cases and Technologies
Yahoo Developer Network
 
October 2016 HUG: The Pillars of Effective Data Archiving and Tiering in Hadoop
Yahoo Developer Network
 
August 2016 HUG: Recent development in Apache Oozie
Yahoo Developer Network
 
August 2016 HUG: Better together: Fast Data with Apache Spark™ and Apache Ign...
Yahoo Developer Network
 

Recently uploaded (20)

PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
July Patch Tuesday
Ivanti
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
July Patch Tuesday
Ivanti
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Biography of Daniel Podor.pdf
Daniel Podor
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

February 2017 HUG: Exactly-once end-to-end processing with Apache Apex

  • 1. Exactly-Once End-To-End Processing with Apache Apex 55th Bay Area Hadoop User Group (HUG) Meetup February 15, 2017
  • 2. Vlad Rozov Apache Apex PMC [email protected] http://github.com/vrozov Engineer at DataTorrent [email protected] CoD fan About me
  • 4. Apache Apex Platform Features • In-memory, distributed stream processing ᵒ Application logic broken into components (operators) that execute distributed in a cluster ᵒ Unobtrusive Java API to express (custom) logic ᵒ Maintain state and metrics in member variables ᵒ Windowing, event-time processing • Scalable, high throughput, low latency ᵒ Operators can be scaled up or down at runtime according to the load and SLA ᵒ Dynamic scaling (elasticity), compute locality • Fault tolerance & correctness ᵒ Automatically recover from node outages without having to reprocess from beginning ᵒ State is preserved, checkpointing, incremental recovery ᵒ End-to-end exactly-once • Operability ᵒ System and application metrics, record/visualize data ᵒ Dynamic changes and resource allocation, elasticity
  • 6. Fault Tolerance • Operator state is checkpointed to persistent store ᵒ Automatically performed by engine, no additional coding needed ᵒ Asynchronous and distributed ᵒ In case of failure operators are restarted from checkpoint state • Automatic detection and recovery of failed containers ᵒ Heartbeat mechanism ᵒ YARN process status notification • Buffering to enable replay of data from recovered point ᵒ Fast, incremental recovery, spike handling • Application master state checkpointed ᵒ Snapshot of physical (and logical) plan ᵒ Execution layer change log
  • 7. Checkpointing Operator State • Save state of operator so that it can be recovered on failure • Pluggable storage handler • Default implementation ᵒ Serialization with Kryo ᵒ All non-transient fields serialized ᵒ Serialized state written to HDFS ᵒ Writes asynchronous, non-blocking • Possible to implement custom handlers for alternative approach to extract state or different storage backend (such as IMDG) • For operators that rely on previous state for computation operators can be marked @Stateless to skip checkpointing • Checkpoint frequency tunable (by default 30s) ᵒ Based on streaming windows for consistent state
  • 8. Sample Failure Scenario … EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1 sum 0 … EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1 sum 7 … EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1 … EW2, 1, 3, BW2, EW1, 4, 2, 1, BW1 sum 7 sum 10
  • 9. At most once At least once Exactly once Subscribes to data from the start of the next window. Operator brought back to its latest checkpointed state and the upstream buffer server replays all subsequent windows Operator brought back to its latest checkpointed state and the upstream buffer server replays all subsequent windows Ignore the lost windows and continue to process incoming data normally. Lost windows are recomputed & application catches up live incoming data Lost windows are recomputed in a logical way to have the effect as if computation has been done exactly once. No duplicates & no recomputation Likely duplicates & recomputation No duplicates & recomputation? Possible missing data No lost data No lost data Processing Guarantees
  • 10. End-to-End Exactly Once • Becomes important when writing to external systems • Data should not be duplicated or lost in the external system even in case of application failures • Common external systems ᵒ Databases ᵒ Files ᵒ Message queues • Platform support for at least once is a must so that no data is lost • Data duplication must still be avoided when data is replayed from checkpoint ᵒ Operators implement the logic dependent on the external system • Aid of platform features such as stateful checkpointing and windowing • Three different mechanisms with implementations explained in next slides
  • 11. Files Streaming data is being written to file on a continuous basis Failure at a random point results in file with an unknown amount of data Operator works with platform to ensure exactly once • Platform responsibility ᵒ Restores state and restarts operator from an earlier checkpoint ᵒ Platform replays data from the exact point after checkpoint • Operator responsibility ᵒ Replayed data doesn’t get duplicated in the file ᵒ Accomplishes by keeping track of file offset as state Existing implementation from Malhar Library AbstractFileOutputOperator.java
  • 12. Exactly Once Strategy File Data Offset Ensures no data is duplicated or lost Chk Operator saves file offset during checkpoint File contents are flushed before checkpoint to ensure there is no pending data in buffer On recovery platform restores the file offset value from checkpoint Operator truncates the file to the offset Starts writing data again
  • 13. Transactional databases 13 Use of streaming windows For exactly once in failure scenarios • Operator uses transactions • Stores window id in a separate table in the database Existing implementation from Malhar Library AbstractJdbcTransactionableOutputOperator.java
  • 14. Exactly Once Strategy d11 d12 d13 d21 d22 d23 lwn1 lwn2 lwn3 op-id wn chk wn wn+1 Lwn+11 Lwn+12 Lwn+13 op-id wn+1 Data Table Meta Table Data in a window is written out in a single transaction Window id is also written to a meta table as part of the same transaction Operator reads the window id from meta table on recovery Ignores data for windows less than the recovered window id and writes new data Partial window data before failure will not appear in data table as transaction was not committed Assumes idempotency for replay
  • 15. Stateful Message Queue 15 Data is being sent to a stateful message queue like Apache Kafka On failure data already sent to message queue should not be re-sent Exactly once strategy • Sends a key along with data that is monotonically increasing • On recovery operator asks the message queue for the last sent message • Gets the recovery key from the message • Ignores all replayed data with key that is less than or equal to the recovered key • If the key is not monotonically increasing then data can be sorted on the key at the end of the window and sent to message queue Existing implementation from Malhar Library: AbstractExactlyOnceKafkaOutputOperator.java
  • 16. Resources Apache Apex - http://apex.apache.org/ Subscribe to forums Apex - http://apex.apache.org/community.html DataTorrent - https://groups.google.com/forum/#!forum/dt-users Download - https://datatorrent.com/download/ Twitter @ApacheApex; Follow - https://twitter.com/apacheapex @DataTorrent; Follow - https://twitter.com/datatorrent Meetups - http://meetup.com/topics/apache-apex Webinars - https://datatorrent.com/webinars/ Videos - https://youtube.com/user/DataTorrent Slides - http://slideshare.net/DataTorrent/presentations Startup Accelerator - Free full featured enterprise product https://datatorrent.com/product/startup-accelerator/ Big Data Application Templates Hub - https://datatorrent.com/apphub