apache flink meetup munich (november 2015): flink overview, architecture, integrations and use cases

61
Stream & Batch Processing with Apache Flink Robert Metzger @rmetzger_ [email protected] Munich Apache Flink Meetup, November 11, 2015

Upload: robert-metzger

Post on 24-Jan-2017

626 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Stream & Batch Processing with Apache Flink

Robert Metzger@[email protected]

Munich Apache Flink Meetup, November 11, 2015

Page 2: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

A bit of historyFrom incubation until now

2

Page 3: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

3

Apr 2014 Jun 2015Dec 2014

0.7

0.6

0.5

0.9

0.9-m1 0.10

Nov 2015

Top level

0.8

Page 4: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Community growth

Flink is one of the largest and most active Apache big data projects with well over 120 contributors

4

Page 5: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Flink meetups around the globe

5

Page 6: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Organizations at Flink Forward

6

Page 7: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Featured in

7

Page 8: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

The streaming eraFlink is all about

8

Page 9: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

9

batch

eventbased

need new systems

well served

Page 10: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

10

Streaming is the biggest change in data infrastructure

since Hadoop

Page 11: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

What is stream processing Real-world data is unbounded and is

pushed to systems Right now: people are using the

batch paradigm for stream analysis (there was no good stream processor available)

New systems (Flink, Kafka) embrace streaming nature of data

11

Web server Kafka topic

Stream processing

Page 12: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

12

Flink is a stream processor with many faces

Streaming dataflow runtime

Page 13: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Flink's streaming runtime

13

Page 14: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Requirements for a stream processor Low latency• Fast results (milliseconds)

High throughput• handle large data amounts (millions of

events per second) Exactly-once guarantees• Correct results, also in failure cases

Programmability• Intuitive APIs

14

Page 15: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Pipelining

15

Basic building block to “keep the data moving”

• Low latency• Operators push

data forward• Data shipping as

buffers, not tuple-wise

• Natural handling of back-pressure

Page 16: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Fault Tolerance in streaming at least once: ensure all operators

see all events• Storm: Replay stream in failure case

Exactly once: Ensure that operators do not perform duplicate updates to their state• Flink: Distributed Snapshots• Spark: Micro-batches on batch runtime

16

Page 17: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Flink’s Distributed Snapshots Lightweight approach of storing the

state of all operators without pausing the execution

high throughput, low latency Implemented using barriers flowing

through the topology

17

Kafka Consume

roffset =

162

Element Countervalue =

152

Operator stateData Stream

barrier

Before barrier =part of the snapshot

After barrier =Not in snapshot

(backup till next snapshot)

Page 18: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

DataStream API

18

case class WordCount(word: String, count: Int)

val text: DataStream[String] = …;

text .flatMap { line => line.split(" ") } .map { word => new WordCount(word, 1) } .keyBy("word") .window(GlobalWindows.create()) .trigger(new EOFTrigger()) .sum("count")

Batch Word Count in the DataStream API

Page 19: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Batch Word Count in the DataSet API

19

case class WordCount(word: String, count: Int)

val text: DataStream[String] = …;

text .flatMap { line => line.split(" ") } .map { word => new WordCount(word, 1) } .keyBy("word") .window(GlobalWindows.create()) .trigger(new EOFTrigger()) .sum("count")

val text: DataSet[String] = …;

text .flatMap { line => line.split(" ") } .map { word => new WordCount(word, 1) } .groupBy("word") .sum("count")

Page 20: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Best of all worlds for streaming Low latency• Thanks to pipelined engine

Exactly-once guarantees• Distributed Snapshots

High throughput• Controllable checkpointing overhead

Programmability • APIs similar to those known from the batch world

20

Page 21: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

21

Throughput of distributed grep

Data Generator

“grep” operator

30 machines, 120 cores

0

20,000,000

40,000,000

60,000,000

80,000,000

100,000,000

120,000,000

140,000,000

160,000,000

180,000,000

200,000,000

aggregate throughput of 175 million elements per second

aggregate throughput of 9 million elements per second

• Flink achieves 20x higher throughput

• Flink throughput almost the same with and without exactly-once

Page 22: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Aggregate throughput for stream record grouping

22

Flink, n

o fault t

olerance

Flink, e

xactly once

Storm

, no fa

ult toleran

ce

Storm

, at le

ast once

0

10,000,000

20,000,000

30,000,000

40,000,000

50,000,000

60,000,000

70,000,000

80,000,000

90,000,000

100,000,000aggregate throughput of 83 million elements per second

8,6 million elements/s

309k elements/s Flink achieves 260x higher throughput with fault tolerance

30 machines, 120 cores Network

transfer

Page 23: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Latency in stream record grouping

23

Data Generator

Receiver:Throughput /

Latency measure

• Measure time for a record to travel from source to sink

Flink,

no fault t

olerance

Flink, e

xactly

once

Storm

, at le

ast once

0.005.00

10.0015.0020.0025.0030.00

Median latency25 ms

1 ms

Flink, no fault toler-ance

Flink, exactly once

Storm, at least

once

0.00

10.00

20.00

30.00

40.00

50.00

60.00

99th percentile latency

50 ms

Page 24: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

24

Page 25: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Exactly-Once with YARN Chaos Monkey Validate exactly-once guarantees

with state-machine

25

Page 26: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Performance: Summary

26

Continuousstreaming

Latency-boundbuffering

DistributedSnapshots

High Throughput &Low Latency

With configurable throughput/latency tradeoff

Page 27: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

“Faces” of Flink

27

Page 28: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Faces of a stream processor

28

Stream processing

Batchprocessing Machine Learning at

scale

Graph Analysis

Streaming dataflow runtime

Page 29: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

The Flink Stack

29

Streaming dataflow runtime

Specialized Abstractions / APIs

Core APIs

Flink Core Runtime

Deployment

Page 30: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

The Flink Stack

30

Streaming dataflow runtime

DataSet (Java/Scala) DataStream (Java/Scala)

Experimental Python API also

available

Data Sourceorders.tbl

FilterMap DataSource

lineitem.tbl

JoinHybrid Hash

buildHT probe

hash-part [0] hash-part [0]

GroupRedsort

forward

API independent DataflowGraph representation

Batch Optimizer Graph Builder

Page 31: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

31

Batch is a special case of streaming

Batch: run a bounded stream (data set) on a stream processor

Form a global window over the entire data set for join or grouping operations

Page 32: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Batch-specific optimizations Managed memory on- and off-heap• Operators (join, sort, …) with out-of-core

support• Optimized serialization stack for user-

types Cost-based Optimizer• Job execution depends on data size

32

Page 33: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

The Flink Stack

33

Streaming dataflow runtime

Specialized Abstractions / APIs

Core APIs

Flink Core Runtime

Deployment

DataSet (Java/Scala) DataStream

Page 34: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

34

FlinkML: Machine Learning API for ML pipelines inspired by scikit-learn

Collection of packaged algorithms • SVM, Multiple Linear Regression, Optimization, ALS, ...

val trainingData: DataSet[LabeledVector] = ...val testingData: DataSet[Vector] = ...

val scaler = StandardScaler()val polyFeatures = PolynomialFeatures().setDegree(3)val mlr = MultipleLinearRegression()

val pipeline = scaler.chainTransformer(polyFeatures).chainPredictor(mlr)

pipeline.fit(trainingData)

val predictions: DataSet[LabeledVector] = pipeline.predict(testingData)

Page 35: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Gelly: Graph Processing Graph API and library

Packaged algorithms• PageRank, SSSP, Label Propagation, Community Detection,

Connected Components

35

ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

Graph<Long, Long, NullValue> graph = ...

DataSet<Vertex<Long, Long>> verticesWithCommunity = graph.run(new

LabelPropagation<Long>(30)).getVertices();

verticesWithCommunity.print();

env.execute();

Page 36: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Flink Stack += Gelly, ML

36

Gelly ML

DataSet (Java/Scala) DataStream

Streaming dataflow runtime

Page 37: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Integration with other systems

37

SAM

OA

DataSet DataStream

Hado

op M

/R

Goog

le D

atafl

ow

Casc

adin

g

Stor

mZepp

elin

• Use Hadoop Input/Output Formats• Mapper / Reducer implementations• Hadoop’s FileSystem implementations

• Run applications implemented against Google’s Data Flow APIon premise with Flink

• Run Cascading jobs on Flink, with almost no code change• Benefit from Flink’s vastly better performance than

MapReduce• Interactive, web-based data exploration

• Machine learning on data streams

• Compatibility layer for running Storm code• FlinkTopologyBuilder: one line replacement for

existing jobs• Wrappers for Storm Spouts and Bolts• Coming soon: Exactly-once with Storm

• Build-in serializer support for Hadoop’s Writable type

Page 38: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Deployment options

Gelly

Table

ML

SAMOA

Data

Set (

Java

/Sca

la)

Data

Stre

am

Hadoop

Loca

lCl

uste

rYA

RNTe

zEm

bedd

edDataflow

Dataflow

MRQL

Table

Cascading

Stre

amin

g da

taflo

w ru

ntim

e

Storm

Zeppelin

• Start Flink in your IDE / on your machine• Local debugging / development using the

same code as on the cluster• “bare metal” standalone installation of Flink

on a cluster

• Flink on Hadoop YARN (Hadoop 2.2.0+)• Restarts failed containers• Support for Kerberos-secured YARN/HDFS

setups

Page 39: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

The full stack

39

Gelly

Tabl

e

ML

SAM

OA

DataSet (Java/Scala) DataStream

Hado

op M

/R

Local Cluster Yarn Tez Embedded

Data

flow

Data

flow

(WiP

)

MRQ

L

Tabl

e

Casc

adin

gStreaming dataflow runtime

Stor

m (W

iP)

Zepp

elin

Page 40: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Flink Use-cases and production users

40

Page 41: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Bouygues Telecom

41

Page 42: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Bouygues Telecom

42

Page 43: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Bouygues Telecom

43

Page 44: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Capital One

44

Page 45: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

45

Page 46: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Closing

46

Page 47: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

47

What is currently happening? Features for upcoming 0.10 release:• Master High Availability• Vastly improved monitoring GUI• Watermarks / Event time processing /

Windowing rework The next talk by Matthias

• Stable streaming API (no more “beta” flag)

Next release: 1.0• API stability

Page 48: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

How do I get started?

48

Mailing Lists: (news | user | dev)@flink.apache.orgTwitter: @ApacheFlink Blogs: flink.apache.org/blog, data-artisans.com/blog/IRC channel: irc.freenode.net#flink

Start Flink on YARN in 4 commands:# get the hadoop2 package from the Flink download page at# http://flink.apache.org/downloads.htmlwget <download url>tar xvzf flink-0.9.1-bin-hadoop2.tgzcd flink-0.9.1/./bin/flink run -m yarn-cluster -yn 4 ./examples/flink-java-examples-0.9.1-WordCount.jar

Page 49: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

49flink.apache.org

• Check out the slides: http://flink-forward.org/?post_type=session

• Video recordings on YouTube, “Flink Forward” channel

Page 50: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Appendix

50

Page 51: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

51

Page 52: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

52

Page 53: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

53

Page 54: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

54

Page 55: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Managed (off-heap) memory and out-of-core support

55Memory runs out

Page 56: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

56

Cost-based Optimizer

DataSourceorders.tbl

FilterMap DataSource

lineitem.tbl

JoinHybrid Hash

buildHT probe

broadcast forward

Combine

GroupRedsort

DataSourceorders.tbl

FilterMap DataSource

lineitem.tbl

JoinHybrid Hash

buildHT probe

hash-part [0] hash-part [0]

hash-part [0,1]

GroupRedsort

forwardBest plan

depends onrelative sizes of

input files

Page 57: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

57

case class Path (from: Long, to: Long)val tc = edges.iterate(10) { paths: DataSet[Path] => val next = paths .join(edges) .where("to") .equalTo("from") { (path, edge) => Path(path.from, edge.to) } .union(paths) .distinct() next }

Optimizer

Type extraction

stack

Task schedulin

g

Dataflow metadata

Pre-flight (Client)

JobManager TaskManagers

Data Sourceorders.tbl

Filter

Map DataSource

lineitem.tbl

JoinHybrid Hash

buildHT

probe

hash-part [0] hash-part [0]

GroupRedsort

forward

Program

DataflowGraph

deployoperators

trackintermediate

results

Loca

lCl

uste

r: YA

RN, S

tand

alon

e

Page 58: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Iterative processing in FlinkFlink offers built-in iterations and delta iterations to execute ML and graph algorithms efficiently

58

map

join sum

ID1

ID2

ID3

Page 59: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

Example: Matrix Factorization

59

Factorizing a matrix with28 billion ratings forrecommendations

More at: http://data-artisans.com/computing-recommendations-with-flink.html

Page 60: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

60

Batch aggregation ExecutionGraph

JobManager

TaskManager 1

TaskManager 2

M1

M2

RP1

RP2

R1

R2

1

2 3a 3b

4a

4b

5a

5b

"Blocked" result partition

Page 61: Apache Flink Meetup Munich (November 2015): Flink Overview, Architecture, Integrations and Use Cases

61

Streaming window aggregation

ExecutionGraph

JobManager

TaskManager 1

TaskManager 2

M1

M2

RP1

RP2

R1

R2

1

2 3a 3b

4a

4b

5a

5b

"Pipelined" result partition