Top Banner
REACTIVE STREAMS, linking REACTIVE APPLICATIONS to SPARK STREAMING Luc Bourlier Lightbend Inc.
29

Reactive Streams, Linking Reactive Application To Spark Streaming

Apr 12, 2017

Download

Data & Analytics

Spark Summit
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Reactive Streams, Linking Reactive Application To Spark Streaming

REACTIVE STREAMS, linking REACTIVE APPLICATIONS to SPARK STREAMING

Luc BourlierLightbend Inc.

Page 2: Reactive Streams, Linking Reactive Application To Spark Streaming

Agenda• Spark Streaming• Reactive Application• Back pressure• Reactive Streams• Demo

Page 3: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark Streaming

Page 4: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark Streaming

Page 5: Reactive Streams, Linking Reactive Application To Spark Streaming

Reactive Application

Page 6: Reactive Streams, Linking Reactive Application To Spark Streaming

Reactive Application

http://www.reactivemanifesto.org

Page 7: Reactive Streams, Linking Reactive Application To Spark Streaming

responds in a timely manner

stays responsive in the face of failure

stays responsive under varying workload

relies on asynchronousmessage-passing

Reactive ApplicationResponsive ResilientElastic Message Driven

Page 8: Reactive Streams, Linking Reactive Application To Spark Streaming
Page 9: Reactive Streams, Linking Reactive Application To Spark Streaming

Resilience in Spark and Spark Streaming

• Support for all kinds of failures– Hardware– Software– Network

• Specific resilience for Spark Streaming– Recovery for continuous processing– Excess volume of data

9

Page 10: Reactive Streams, Linking Reactive Application To Spark Streaming

Resilience in Spark and Spark Streaming

• Support for all kinds of failures– Hardware– Software– Network

• Specific resilience for Spark Streaming– Recovery for continuous processing– Excess volume of data

10

the subject ofthis presentation

Page 11: Reactive Streams, Linking Reactive Application To Spark Streaming

Demo

Page 12: Reactive Streams, Linking Reactive Application To Spark Streaming

Demo

Image, Wikipedia. By CaitlinJo - Own workThis mathematical image was created with Mathematica, CC BY 3.0

RNG pair mergeInt

(Int, Int)sliced

in/out

over all values

per slices

per windows

Boolean

π

in/out

over all values

per slices

per windows

Boolean(Int, Int)windowed

ReactiveApplication

SparkStreaming

receiver StatisticalAnalysis

RDDs

Page 13: Reactive Streams, Linking Reactive Application To Spark Streaming

Back Pressure

Page 14: Reactive Streams, Linking Reactive Application To Spark Streaming

Back Pressure• a slow consumer should slow down the

producer– the produce applies pressure– the consumer applies back pressure

• the classic example: TCP

Page 15: Reactive Streams, Linking Reactive Application To Spark Streaming

Back Pressure in Spark Streaming

Page 16: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark StreamingCongestion support in Spark 1.4Static rate limit

• spark.streaming.receiver.maxRate

• conservative• difficult to find the right limit (depends on cluster size)• one limit to all streams

Page 17: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark StreamingBack pressure in Spark 1.5Dynamic rate limit

• rate estimator– estimates the number of element that can be safely processed by

system during the batch interval

• rate sent to receivers• rate limiter

– relies on TCP to slow down producers

Page 18: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark StreamingRate estimator• each BatchCompleted event contains

– processing delay, scheduling delay– number of element in mini-batch

• the rate is (roughly) elements / processingDelay• but what about accumulated delay?

Page 19: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark StreamingRate estimator

Proportional-Integral-Derivative• P, I, D constants change

convergence, overshooting

and oscillations

https://en.wikipedia.org/wiki/PID_controller

Page 20: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark StreamingBack pressure in Spark 1.5

• each input has its own estimator• work with all stream receivers

including KafkaDirectInputStream• configuration

– spark.streaming.backpressure.enable true– spark.streaming.backpressure.minRate R

Page 21: Reactive Streams, Linking Reactive Application To Spark Streaming
Page 22: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark StreamingLimitations

• linearity assumption• records with similar execution times• TCP back pressure accumulates in the TCP channel

Page 23: Reactive Streams, Linking Reactive Application To Spark Streaming

Reactive Streams

Page 24: Reactive Streams, Linking Reactive Application To Spark Streaming

Reactive Streams• one tool to create reactive applications• specification for back pressure interface to connect

systems supporting back pressure in the JVM– small: 3 interfaces, 7 methods total

• subscriber controls rate by requesting elements from producers

http://www.reactive-streams.org

Page 25: Reactive Streams, Linking Reactive Application To Spark Streaming

End to end back pressure

Page 26: Reactive Streams, Linking Reactive Application To Spark Streaming

End to end back pressure• Reactive application with reactive streams

connector⇒ back pressure enabled

• Spark Streaming 1.5+⇒ back pressure enabled

• Reactive streams Spark Streaming receiver⇒ end to end back pressure

Page 27: Reactive Streams, Linking Reactive Application To Spark Streaming

Demo

Page 28: Reactive Streams, Linking Reactive Application To Spark Streaming

Spark 2.x ?● Spark Streaming still available

○ same support

● Structured Streaming○ experimental, no stable source API○ different model○ requires an updated solution

Page 29: Reactive Streams, Linking Reactive Application To Spark Streaming

THANK [email protected]