An Introduction to Distributed Data Streaming Elements and Systems - - PowerPoint PPT Presentation

an introduction to distributed data streaming
SMART_READER_LITE
LIVE PREVIEW

An Introduction to Distributed Data Streaming Elements and Systems - - PowerPoint PPT Presentation

An Introduction to Distributed Data Streaming Elements and Systems Paris Carbone<parisc@kth.se> PhD Candidate KTH Royal Institute of Technology 1 2 2 2 how to avoid this? 2 how to avoid this? 2 Q how to avoid this? 2 Q Q = +


slide-1
SLIDE 1

An Introduction to Distributed Data Streaming

Elements and Systems

Paris Carbone<parisc@kth.se> PhD Candidate KTH Royal Institute of Technology

1

slide-2
SLIDE 2

2

slide-3
SLIDE 3

2

slide-4
SLIDE 4

2

slide-5
SLIDE 5

2

how to avoid this?

slide-6
SLIDE 6

2

how to avoid this?

slide-7
SLIDE 7

2

how to avoid this?

Q

slide-8
SLIDE 8

2

how to avoid this?

Q =

+

Q

slide-9
SLIDE 9

Motivation

3

Q =

+

slide-10
SLIDE 10

Motivation

3

Q =

+

slide-11
SLIDE 11

Motivation

3

Q Q Q =

+

slide-12
SLIDE 12

Motivation

3

Q Q Q =

+

slide-13
SLIDE 13

Motivation

3

Q Q Q =

+

slide-14
SLIDE 14

Motivation

4

Q

Standing Query

slide-15
SLIDE 15

Motivation

4

Q

Standing Query

slide-16
SLIDE 16

Motivation

4

Q

Standing Query

slide-17
SLIDE 17

Motivation

4

Q

Standing Query

slide-18
SLIDE 18

Preliminaries

  • Data Streaming Paradigm
  • Incoming data is unbound - continuous arrival
  • Standing queries are evaluated continuously
  • Queries operate on the full data stream or on the

most recent views of the stream ~ windows

5

slide-19
SLIDE 19

Data Streams Basics

  • Events/Tuples : elements of computation - respect a schema
  • Data Streams : unbounded sequences of events
  • Stream Operators: consume streams and generate new ones.
  • Events are consumed once - no backtracking!

6

f

S1 S2 So S’1 S’2

slide-20
SLIDE 20

Streaming Pipelines

7

stream1 stream2

approximations predictions alerts ……

Q

sources sinks

slide-21
SLIDE 21

Core Abstractions

  • Windows
  • Synopses (summary state)
  • Partitioning

8

slide-22
SLIDE 22

Windows

Discussion Why do we need windows?

9

slide-23
SLIDE 23

Windows

  • We are often interested only in fresh data
  • f = “average temperature over the last minute every 20 sec”
  • Range: Most data stream processing systems allow window
  • perations on the most recent history (eg. 1 minute, 1000 tuples)
  • Slide: The frequency/granularity f is evaluated on a given range

10

#seconds 40 80 Average #3 Average #2 Average #1 20 60 100

f

W: 1min, 20sec

slide-24
SLIDE 24

Window Types

11

#sec 40 80

Average #2 Average #1

20 60 100 #sec 40 80

Average #3 Average #2 Average #1

20 60 100 #sec 40 80

Average #2 Average #1

20 60 100 120 120

Sliding Tumbling Jumping

range > slide range = slide range < slide

slide-25
SLIDE 25

Synopses

We cannot infinitely store all events seen

  • Synopsis: A summary of an infinite stream
  • It is in principle any streaming operator state
  • Examples: samples, histograms, sketches, state machines…

12

f s

a summary of everything seen so far

  • 1. process t, s
  • 2. update s
  • 3. produce t’

t t’

What about window synopses?

slide-26
SLIDE 26

Synopses-Aggregations

  • Discussion - Rolling Aggregations
  • Propose a synopsis, s=? when
  • f= max
  • f= ArithmeticMean
  • f= stDev

13

slide-27
SLIDE 27

Synopses-Approximations

14

  • Discussion - Approximate Results
  • Propose a synopsis, s=? when
  • f= uniform random sample of k records over the

whole stream

  • f= filter distinct records over windows of 1000

records with a 5% error

slide-28
SLIDE 28

Synopses-ML and Graphs

15

  • Examples of cool synopses to check out
  • Sparsifiers/Spanners - approximating graph

properties such as shortest paths

  • Change detectors - detecting concept drift
  • Incremental decision trees - continuous stream

training and classification

slide-29
SLIDE 29

Partitioning

  • One stream operator is not enough
  • Data might be too large to process
  • e.g. very high input rate, too many stream sources
  • State could possibly not fit in memory

16

f

s

f

s

f

s

parallel instances

How do we partition the input streams?

f

s
slide-30
SLIDE 30

Partitioning

  • Partitioning defines how we allocate events to each

parallel instance. Typical partitioners are:

  • Broadcast
  • Shuffle
  • Key-based

17

f

s

f

s

f

s

f

s

f

s

f

s

P P P

by color

slide-31
SLIDE 31

Putting Everything Together

18

Fire Detection Pipeline

{area,temp} {area,smoke} {loc,alert!}

  • operators
  • synopses
  • windows
  • partitioning

trigger

  • n detection

trigger periodically

?

slide-32
SLIDE 32

Operators

19

A

s

F

s

Rolling Arithmetic Mean of Temperatures State Machine-based Fire Alarm

{area,temp} {area,avgTemp} {alarm}

Src

Sensor Data Sources

{area,temp}

Src

{area} Periodic Temperature Updates Smoke Detections trivial… What is the state and its transitions?

slide-33
SLIDE 33

Partitioning

  • We are only interested in correlating smoke and

high temperature within the same area

  • Events carry area information so we can partition
  • ur computation by area

20

Src

P

key:area

slide-34
SLIDE 34

Windowing

  • Individual sensor data could be potentially faulty
  • We need to gather data from all temperature sensors
  • f an area and produce an average
  • We want fresh average temperatures

21

Src

P

key:area

{area,temp}

A

s

A

s

w w w = ?

slide-35
SLIDE 35

The Fire Alarm

22

slide-36
SLIDE 36

The Fire Alarm

22

F

s
slide-37
SLIDE 37

The Fire Alarm

22

F

s

T : avgTemp>40 T : avgTemp<40 S : Smoke

slide-38
SLIDE 38

The Fire Alarm

22

F

s

T : avgTemp>40 T : avgTemp<40 …TTTSTTSTTTT…. S : Smoke

slide-39
SLIDE 39

The Fire Alarm

22

F

s

T : avgTemp>40 T : avgTemp<40 …TTTSTTSTTTT….

OK HOT SMOKE FIRE

T T T S S T T S : Smoke

slide-40
SLIDE 40

The Fire Alarm

22

F

s

T : avgTemp>40 T : avgTemp<40 …TTTSTTSTTTT….

OK HOT SMOKE FIRE

T T T S S T T synopsis= 1 state S : Smoke

slide-41
SLIDE 41

Putting Everything Together

23

{area,temp} {area,smoke}

Src Src

P P A

s

A

s

key:area key:area

w w F

s

F

s

P

key:area {area, alert}

{area,avg_temp} {area,smoke}

slide-42
SLIDE 42

Systems: The Big Picture

24

Proprietary Open Source Google DataFlow IBM Infosphere Microsoft Azure Flink Storm Samza Spark

slide-43
SLIDE 43

Evolution

25

’95 Materialised Views ’01 Complex Event Processing ’03 TelegraphCQ ’03 STREAM ’05 Borealis ’15 User-Defined Windows ’12 Policy-Based Windowing ’88 Active DataBases ’88 HiPac ’12 Twitter Storm ’12 IBM System S ’13 Spark Streaming ’14 Apache Flink ’13 Parallel Recovery ’05 Decentralised Stream Queries ’05 High Availability

  • n Streaming

concepts systems

’13 Google Millwheel ’13 Discretized Streams ’00 Eddies 02 Aurora ’12 Twitter Storm

slide-44
SLIDE 44

Programming Models

26

Compositional Declarative

  • Offer basic building blocks

for composing custom

  • perators and topologies
  • Advanced behaviour such

as windowing is often missing

  • Custom Optimisation
  • Expose a high-level API
  • Operators are higher order

functions on abstract data stream types

  • Advanced behaviour such

as windowing is supported

  • Self-Optimisation
slide-45
SLIDE 45

Programming Model Types

27

DStream, DataStream, PCollection…

  • Direct access to the

execution graph / topology

  • Suitable for engineers
  • Transformations abstract
  • perator details
  • Suitable for engineers

and data analysts

slide-46
SLIDE 46

Standing Queries with Apache Storm

28

  • Step1: Implement input (Spouts) and intermediate operators

(Bolts)

  • Step 2: Construct a Topology by combining operators

Spout Bolt Bolt

Spouts are the topology sources The listen to data feeds Bolts represent all intermediate computation vertices of the topology They do arbitrary data manipulation Each operator can emit/subscribe to Streams (computation results)

slide-47
SLIDE 47

Example: Topology Definition

29 numbers

new_numbers

numbers

new_numbers toFile

slide-48
SLIDE 48

Standing Queries with Apache Flink

30

Flink Runtime Flink Job Graph Builder/Optimiser Flink Client

Streaming Program

  • Operator fusion
  • Window Pre-aggregates
  • Deploy Long Running Tasks
  • Monitor Execution
slide-49
SLIDE 49

Distributed Stream Execution Paradigms

31

(Hadoop, Spark) (Spark Streaming)

1) Real Streaming (Distributed Data Flow)

LONG-LIVED TASK EXECUTION STATE IS KEPT INSIDE TASKS

2) Batched Execution

slide-50
SLIDE 50

Windows in Action

32

  • DStreams are already

partitioned in time windows

  • Only time windows supported
  • Windows decomposed into

policies

  • Policies can be user-defined too

range slide

slide-51
SLIDE 51

Windows on Storm?

33

src-http://www.michael-noll.com/blog/2013/01/18/implementing-real-time-trending-topics-in-storm/

slide-52
SLIDE 52

Partitioning in Action

34

forward() shuffle() broadcast() keyBy() partitionCustom() shuffleGrouping() allGrouping() fieldsGrouping() customGrouping() repartition(num) reduceByKey() updateStateByKey()

no fine-grained control full control

slide-53
SLIDE 53

Synopses in Action

35

implementing a rolling max per key

slide-54
SLIDE 54

State in Spark?

36

  • Streams are partitioned into small batches
  • There is practically no state kept in workers (stateless)
  • How do we keep state??

(Spark Streaming)

put new states in output RDD

dstream.updateStateByKey(…)

In S’

slide-55
SLIDE 55

Implementing the alarm in Flink

37

slide-56
SLIDE 56

So everything works

38

{area,temp} {area,smoke}

Src Src

P P A

s

A

s

key:area key:area

w w F

s

F

s

P

key:area

{area,avg_temp} {area,smoke}

  • r…
slide-57
SLIDE 57

Unreliable Sources

39

Standing Query

Q

slide-58
SLIDE 58

Unreliable Sources

39

Standing Query

Q

slide-59
SLIDE 59

Unreliable Sources

39

Standing Query

Q

slide-60
SLIDE 60

Unreliable Sources

39

Standing Query

add more sensors

Q

slide-61
SLIDE 61

Unreliable Processing

40

Standing Query

Q

slide-62
SLIDE 62

Unreliable Processing

40

Standing Query

Q

slide-63
SLIDE 63

recovered!

Unreliable Processing

40

Standing Query

Q

slide-64
SLIDE 64

recovered!

Unreliable Processing

40

Standing Query

Q

lost smoke events

slide-65
SLIDE 65

Resilient Brokers

Main Features

  • Topic-based partitioned queues
  • Strongly consistent offset mapping to records

41

slide-66
SLIDE 66

Processing Guarantees

  • Kafka solves the source consistency problem
  • How about the rest of the states of the computation ? (e.g. alert
  • perator state)
  • Each system offers different guarantees

42

Guarantees Technique Storm at least once event dependency tracking Spark exactly once source upstream backup Flink exactly once periodic snapshots

slide-67
SLIDE 67

43

Q

Standing Query

Mission Accomplished

slide-68
SLIDE 68

Research Topics at KTH/SICS

  • Exactly-Once-Output Guarantees
  • State management and auto-scaling
  • Streaming ML pipelines
  • Streaming Graphs

44