14
Reactive Streams Fehmi Can Sağlam

Reactive Streams

Embed Size (px)

Citation preview

Page 1: Reactive Streams

Reactive StreamsFehmi Can Sağlam

Page 2: Reactive Streams

Producer-Consumer Pattern

• Separate work and executor • Readable / Maintainable

Page 3: Reactive Streams

Linked By a Queue

• Decoupled architecture • Producer places work into the buffer • Consumer takes work from the buffer

Page 4: Reactive Streams

Multiple Producers/Consumers

• Enabled by decoupled architecture

Page 5: Reactive Streams

Problem

• Unbounded buffer = Out Of Memory • Bounded buffer = Dropping messages

Page 6: Reactive Streams

Solution

BACK-PRESSURE

Page 7: Reactive Streams

StreamsWhat is a stream?

A stream is like a river of data. If you are late, you may miss initial elements.

Page 8: Reactive Streams

Stream examples

• Real-time data sources • Monitoring and analytics • Bulk data transfer • Batch processing of large data

Page 9: Reactive Streams

Reactive Streams

• Stream processing • Back-pressured • Asynchronous • Standardised

Engineers from: • Netflix • Oracle • Pivotal • Red Hat • Twitter • Typesafe (Lightbend)

Page 10: Reactive Streams

Pull-based Back-pressure

Fast producer will send at-most 3 elements.

Page 11: Reactive Streams

Accumulated requests

Producer accumulates total demand.

Page 12: Reactive Streams

Specification

Page 13: Reactive Streams

Akka Streams

Tepkin (Reactive MongoDB client) supports Akka Streams

Page 14: Reactive Streams

ThanksFehmi Can Sağlam

fehmicansaglam.net twitter.com/fehmicans

github.com/fehmicansaglam