The Power of Snapshots Stateful Stream Processing with Apache Flink

Similar documents
Modern Stream Processing with Apache Flink

Streaming Analytics with Apache Flink. Stephan

The Stream Processor as a Database. Ufuk

Apache Flink Big Data Stream Processing

WHY AND HOW TO LEVERAGE THE POWER AND SIMPLICITY OF SQL ON APACHE FLINK - FABIAN HUESKE, SOFTWARE ENGINEER

Apache Flink. Alessandro Margara

Real-time data processing with Apache Flink

The Future of Real-Time in Spark

Putting it together. Data-Parallel Computation. Ex: Word count using partial aggregation. Big Data Processing. COS 418: Distributed Systems Lecture 21

A Distributed System Case Study: Apache Kafka. High throughput messaging for diverse consumers

Extending Flink s Streaming APIs

What is wrong with PostgreSQL? OR What does Oracle have that PostgreSQL should? Richard Stephan

Streaming analytics better than batch - when and why? _Adam Kawa - Dawid Wysakowicz_

ebay Marketplace Architecture

Big Data Technology Incremental Processing using Distributed Transactions

PostgreSQL migration from AWS RDS to EC2

data Artisans Streaming Ledger

MarkLogic Technology Briefing

Container 2.0. Container: check! But what about persistent data, big data or fast data?!

Data Acquisition. The reference Big Data stack

Using the SDACK Architecture to Build a Big Data Product. Yu-hsin Yeh (Evans Ye) Apache Big Data NA 2016 Vancouver

ebay s Architectural Principles

Microsoft Azure Databricks for data engineering. Building production data pipelines with Apache Spark in the cloud

An Information Asset Hub. How to Effectively Share Your Data

Microsoft SQL Server

Down the event-driven road: Experiences of integrating streaming into analytic data platforms

Deep Dive Amazon Kinesis. Ian Meyers, Principal Solution Architect - Amazon Web Services

Designing Database Solutions for Microsoft SQL Server (465)

Data Acquisition. The reference Big Data stack

Databricks Delta: Bringing Unprecedented Reliability and Performance to Cloud Data Lakes

MINIMIZING TRANSACTION LATENCY IN GEO-REPLICATED DATA STORES

Windows Azure Services - At Different Levels

High Availability- Disaster Recovery 101

HBase Solutions at Facebook

10. Replication. CSEP 545 Transaction Processing Philip A. Bernstein. Copyright 2003 Philip A. Bernstein. Outline

MarkLogic Server. Database Replication Guide. MarkLogic 9 May, Copyright 2017 MarkLogic Corporation. All rights reserved.

MAPR TECHNOLOGIES, INC. TECHNICAL BRIEF APRIL 2017 MAPR SNAPSHOTS

Deep Dive into Concepts and Tools for Analyzing Streaming Data

Using Apache Beam for Batch, Streaming, and Everything in Between. Dan Halperin Apache Beam PMC Senior Software Engineer, Google

Griddable.io architecture

Oracle Database 18c and Autonomous Database

Distributed ETL. A lightweight, pluggable, and scalable ingestion service for real-time data. Joe Wang

Availability and Performance for Tier1 applications

Postgres-XC PostgreSQL Conference Michael PAQUIER Tokyo, 2012/02/24

Turning Relational Database Tables into Spark Data Sources

Towards a Real- time Processing Pipeline: Running Apache Flink on AWS

Fluentd + MongoDB + Spark = Awesome Sauce

10. Replication. CSEP 545 Transaction Processing Philip A. Bernstein Sameh Elnikety. Copyright 2012 Philip A. Bernstein

Flash Storage Complementing a Data Lake for Real-Time Insight

Apache Ignite and Apache Spark Where Fast Data Meets the IoT

Apache Spark Tutorial

S-Store: Streaming Meets Transaction Processing

The SMACK Stack: Spark*, Mesos*, Akka, Cassandra*, Kafka* Elizabeth K. Dublin Apache Kafka Meetup, 30 August 2017.

Esper EQC. Horizontal Scale-Out for Complex Event Processing

DRIZZLE: FAST AND Adaptable STREAM PROCESSING AT SCALE

Hi! NET Developer Group Braunschweig!

ARIES (& Logging) April 2-4, 2018

Dynamically Configured Stream Processing Using Flink & Kafka

Focus On: Oracle Database 11g Release 2

Lecture Notes to Big Data Management and Analytics Winter Term 2017/2018 Apache Flink

Data Protection Modernization: Meeting the Challenges of a Changing IT Landscape

CS122 Lecture 15 Winter Term,

arxiv: v1 [cs.dc] 29 Jun 2015

Data Infrastructure at LinkedIn. Shirshanka Das XLDB 2011

TRANSACTIONS OVER HBASE

8/24/2017 Week 1-B Instructor: Sangmi Lee Pallickara

We are ready to serve Latest Testing Trends, Are you ready to learn?? New Batches Info

Evolution of an Apache Spark Architecture for Processing Game Data

NPTEL Course Jan K. Gopinath Indian Institute of Science

Database Management System

DESIGNING DATABASE SOLUTIONS FOR MICROSOFT SQL SERVER CERTIFICATION QUESTIONS AND STUDY GUIDE

ARCHITECTING WEB APPLICATIONS FOR THE CLOUD: DESIGN PRINCIPLES AND PRACTICAL GUIDANCE FOR AWS

Over the last few years, we have seen a disruption in the data management

Introduction to Apache Apex

High Availability- Disaster Recovery 101

SQL Server SQL Server 2008 and 2008 R2. SQL Server SQL Server 2014 Currently supporting all versions July 9, 2019 July 9, 2024

TRANSACTIONS AND ABSTRACTIONS

Apache Flink- A System for Batch and Realtime Stream Processing

PNUTS: Yahoo! s Hosted Data Serving Platform. Reading Review by: Alex Degtiar (adegtiar) /30/2013

Streaming data Model is opposite Queries are usually fixed and data are flows through the system.

Postgres-XC PG session #3. Michael PAQUIER Paris, 2012/02/02

Lecture 21 11/27/2017 Next Lecture: Quiz review & project meetings Streaming & Apache Kafka

Practical Big Data Processing An Overview of Apache Flink

Managing IoT and Time Series Data with Amazon ElastiCache for Redis

Architecture of Flink's Streaming Runtime. Robert

Microsoft SQL Server" 2008 ADMINISTRATION. for ORACLE9 DBAs

MarkLogic Server. Database Replication Guide. MarkLogic 6 September, Copyright 2012 MarkLogic Corporation. All rights reserved.

@unterstein #bedcon. Operating microservices with Apache Mesos and DC/OS

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into

PREDICTIVE DATACENTER ANALYTICS WITH STRYMON

WHITEPAPER. MemSQL Enterprise Feature List

SQL SERVER DBA TRAINING IN BANGALORE

IOTA ARCHITECTURE: DATA VIRTUALIZATION AND PROCESSING MEDIUM DR. KONSTANTIN BOUDNIK DR. ALEXANDRE BOUDNIK

Enterprise Open Source Databases

Database Engineering. Percona Live, Amsterdam, September, 2015

Flexible Network Analytics in the Cloud. Jon Dugan & Peter Murphy ESnet Software Engineering Group October 18, 2017 TechEx 2017, San Francisco

Fast and Easy Stream Processing with Hazelcast Jet. Gokhan Oner Hazelcast

Cloudline Autonomous Driving Solutions. Accelerating insights through a new generation of Data and Analytics October, 2018

Percona Live September 21-23, 2015 Mövenpick Hotel Amsterdam

Using VMware vsphere with Your System

Transcription:

The Power of Snapshots Stateful Stream Processing with Apache Flink Stephan Ewen QCon San Francisco, 2017 1

Original creators of Apache Flink da Platform 2 Open Source Apache Flink + da Application Manager 2

Stream Processing 3

What changes faster? Data or Query? Data changes slowly compared to fast changing queries ad-hoc queries, data exploration, ML training and (hyper) parameter tuning Batch Processing Use Case Data changes fast application logic is long-lived continuous applications, data pipelines, standing queries, anomaly detection, ML evaluation, Stream Processing Use Case 4

Batch Processing 5

Stream Processing 6

Stateful Stream Processing 7

Moving State into the Processors Application Application state state External DB Stateless Stream Processor Stateful Stream Processor 8

Apache Flink 9

Apache Flink in a Nutshell Stateful computations over streams real-time and historic fast, scalable, fault tolerant, in-memory, event time, large state, exactly-once Queries Application Applications Devices etc. Streams Historic Data Database Stream File / Object Storage 10

The Core Building Blocks Event Streams State (Event) Time Snapshots real-time and hindsight complex business logic consistency with out-of-order data and late data forking / versioning / time-travel 11

Stateful Event & Stream Processing val lines: DataStream[String] = env.addsource(new FlinkKafkaConsumer09( )) val events: DataStream[Event] = lines.map((line) => parse(line)) val stats: DataStream[Statistic] = stream.keyby("sensor").timewindow(time.seconds(5)).sum(new MyAggregationFunction()) stats.addsink(new RollingSink(path)) Source Transformation Transformation Sink Source Transform Window (state read/write) Sink Streaming Dataflow 12

Stateful Event & Stream Processing Scalable embedded state Access at memory speed & scales with parallel operators 13

Event time and Processing Time Event Producer Message Queue Flink Data Source Flink Window Operator partition 1 partition 2 Event Time Broker Time Ingestion Time Processing Time Event time, Watermarks, as in the Dataflow model 14

Powerful Abstractions Layered abstractions to navigate simple to complex use cases High-level Analytics API Stream- & Batch Data Processing Stream SQL / Tables (dynamic tables) DataStream API (streams, windows) val stats = stream.keyby("sensor").timewindow(time.seconds(5)).sum((a, b) -> a.add(b)) Stateful Event- Driven Applications Process Function (events, state, time) def processelement(event: MyEvent, ctx: Context, out: Collector[Result]) = { // work with event and state (event, state.value) match { } out.collect( ) // emit events state.update( ) // modify state // schedule a timer callback ctx.timerservice.registereventtimetimer(event.timestamp + 500) } 15

Distributed Snapshots 16

Event Sourcing + Memory Image periodically snapshot the memory main memory event / command event log persists events (temporarily) update local variables/structures Process 17

Event Sourcing + Memory Image Recovery: Restore snapshot and replay events since snapshot event log persists events (temporarily) Process 18

Consistent Distributed Snapshots Scalable embedded state Access at memory speed & scales with parallel operators 19

Checkpoint Barriers 20

Consistent Distributed Snapshots Trigger checkpoint Inject checkpoint barrier 21

Consistent Distributed Snapshots Take state snapshot Trigger state copy-on-write 22

Consistent Distributed Snapshots Persist state snapshots Processing pipeline continues Persist snapshots asynchronously 23

Consistent Distributed Snapshots Rolling back computation Re-processing Re-load state Reset positions in input streams 25

Consistent Distributed Snapshots Restore to different programs 26

Checkpoints and Savepoints in Apache Flink 27

Speed or Operability? What to optimize for? Fast snapshots Checkpoint Flexible Operations on Snapshots Savepoint 28

Savepoints: Opt. for Operability Self contained: No references to other checkpoints Canonical format: Switch between state structures Efficiently re-scalable: Indexed by key group Future: More self-describing serialization format for to archiving / versioning (like Avro, Thrift, etc.) 29

Checkpoints: Opt. for Efficiency Often incremental: Snapshot only diff from last snapshot Reference older snapshots, compaction over time Format specific to state backend: No extra copied or re-encoding Not possible to switch to another state backend between checkpoints Compact serialization: Optimized for speed/space, not long term archival and evolution Key goups not indexed: Re-distribution may be more expensive 30

What else are snapshots / checkpoints good for? 31

What users built on checkpoints Upgrades and Rollbacks Cross Datacenter Failover State Archiving State Bootstrapping Application Migration Spot Instance Region Arbitrage A/B testing 32

Distributed Snapshots and side effects 33

Transaction coordination for side fx Snapshots may include side effects One snapshot can transactionally move data between different systems 34

Transaction coordination for side fx Similar to a distributed 2-phase commit Coordinated by asynchronous checkpoints, no voting delays Basic algorithm: Between checkpoints: Produce into transaction or Write Ahead Log On operator snapshot: Flush local transaction (vote-to-commit) On checkpoint complete: Commit transactions (commit) On recovery: check and commit any pending transactions 35

Distributed Snapshots and Application Architectures (A Philosophical Monologue) 36

Good old centralized architecture Application Application Application Application $$$ The big mean central database The grumpy DBA 37

Stateful Stream Proc. & Applications Application Application Application decentralized infrastructure decentralized responsibilities DevOps Application Application still involves managing databases 38

Stateless Application Containers State management is nasty, let's pretend we don't have to do it 39

Stateless Application Containers Broccoli (state management) is nasty, let's pretend we don't have to eat do it Kudos to Kiki Carter for the Broccoli Metaphor 40

Stateful Stream Proc. to the rescue very simple: state is just part of the application Application Application Sensor Application APIs Application 41

Compute, State, and Storage Classic tiered architecture compute layer Streaming architecture compute + application state database layer application state + backup stream storage and snapshot storage (backup) 42

Performance Classic tiered architecture Streaming architecture synchronous reads/writes across tier boundary all modifications are local asynchronous writes of large blobs 43

Consistency Classic tiered architecture Streaming architecture exactly once per state =1 =1 distributed transactions at scale typically at-most / at-least once 44

Scaling a Service Classic tiered architecture Streaming architecture provision compute provision compute and state together separately provision additional database capacity 45

Rolling out a new Service Classic tiered architecture Streaming architecture provision compute and state together provision a new database (or add capacity to an existing one) simply occupies some additional backup space 46

Time, Completeness, Out-of-order Classic tiered architecture? event time clocks define data completeness event time timers handle actions for out-of-order data Streaming architecture 47

Stateful Stream Processing very simple: state is just part of the application Application Application Sensor Application APIs Application 48

The Challenges with that: Upgrades are stateful, need consistency application evolution and bug fixes Migration of application state cluster migration, A/B testing Re-processing and reinstatement fix corrupt results, bootstrap new applications State evolution (schema evolution) 49

The answer (my personal and obviously biased take) Consistent Distributed Snapshots 50

Demo Time! Payments Dashboard 51

Thank you very much (shameless plug) 52

We are hiring! data-artisans.com/careers

Appendix 54

Details about Snapshots and Transactional Side Effects 55

Exactly-once via Transactions global chk-1 chk-1 global chk-2 chk-2 TXN-1 TXN-2 TXN-3 Side effect 56

Transaction fails after local snapshot global chk-1 chk-2 chk-1 TXN-1 TXN-2 TXN-3 Side effect 57

Transaction fails before commit global chk-1 chk-1 global chk-2 TXN-1 TXN-2 TXN-3 Side effect 58

commit on recovery global chk-2 chk-3 recover TXN handle TXN-2 TXN-3 Side effect 59