6 years later
Krzysztof Ciesielski
@kpciesielski
22.08.2013, Jonas Boner
16.09.2014 version 2.0
Jonas Bonér, Dave Farley, Roland Kuhn, and Martin Thompson. With the help and refinement of many members in the community.
Another buzzword?
Has it got adapter like "Microservices"?
Or rather ended up like "BigData"?
versus
Main goal of the Manifesto
means:
scalability
reacting to changing load = elastic)
failure isolation (resilient)
simpler deployments
better maintainability
Communication: asynchronous, often non-blocking
Reactive Systems rely on asynchronous message-passing to establish a boundary between components that ensures loose coupling, isolation and location transparency. This boundary also provides the means to delegate failures as messages.
Samza, Spark Streaming, Flink, AWS Kinesis
Development powered by Machine Learning
Why reactive?
elastic, fault-tolerant (resilience)
"reacting to changes"
DevOps/Cloud explosion
Kubernetes, AWS (Fargate), sophisticated monitoring and alerting (like VictorOps)
Practices and tools for building code which is:
Describing processing logic, not flow control.
Description of transformations
Observer pattern
Hollywood Principle ("Don't call us, we'll call you")
Source: https://www.tomaszezula.com/2018/12/10/observer-pattern-in-rxjava/
Future[T] / scalaz Task[T]
Actor Model
RxJava
Vert.x
2014
What is happening in the JVM ecosystem
Reactive Streams
Akka Streams
scalaz-stream
Apache Kafka 0.8.1
2014
What is happening in the JVM ecosystem
Vaughn Vernon
Reactive Messaging Patterns with the Actor Model
2015
Work Pulling (Akka)
Source: https://redsigil.weebly.com/home/akka-work-pulling-pattern-and-some-background
Project Reactor (Java)
Source: https://speakerdeck.com/simonbasle/projectreactor-dot-io-reactor3-intro
2015
Source: https://speakerdeck.com/simonbasle/projectreactor-dot-io-reactor3-intro
2015
Project Reactor (Java)
Spring Framework 5 embraces Reactive Streams and Reactor for its own reactive use as well as in many of its core APIs.
Source: http://mdabrowski.net/spring-boot-2-reaktywny-spring-webflux/
2016
Akka Persistence, Streams + Alpakka
Kafka 2.3
RxJava
Vert.x
Functional Reactive Programming (FRP)
Cats-Effect, Monix, ZIO
2019
val streamGraph = tweets
.filter(_.hashtags contains akkaTag)
.buffer(1000)
.map(t => 1)
.toMat(Sink.fold[Int, Int](0)(_ + _))(Keep.right)
val result: Future[Int] = streamGraph.run()
2019
val streamGraph = tweets
.filter(_.hashtags contains akkaTag)
.buffer(1000)
.map(t => 1)
.toMat(Sink.fold[Int, Int](0)(_ + _))(Keep.right)
val result: Future[Int] = streamGraph.run()
def process(tweet: Tweet): Future[ProcessedTweet] = ???
val streamGraph = tweets
.filter(_.hashtags contains akkaTag)
.mapAsync(parallelism = 3)(process)
.toMat(sink)(Keep.right)
Akka Streams + Alpakka, Kafka 2.3
val ks: UniqueKillSwitch =
RestartSource
.withBackoff(
minBackoff = config.restart.minBackoff,
maxBackoff = config.restart.maxBackoff,
randomFactor = config.restart.randomFactor
)(() => {
eventSource
.via(preProcessFlow)
.via(pipeline)
.via(postProcessFlow)
.withAttributes(supervisionStrategy(decider))
})
.viaMat(KillSwitches.single)(Keep.right)
.toMat(Sink.ignore)(Keep.left)
.run()
2019
zio-kafka
val consumer = Consumer.make(consumerSettings, Serde.string, Serde.string.asTry)
val stream = Consumer
.subscribeAnd[Any, String, Try[String]](Subscription.topics("topic150"))
.plainStream
stream
.mapM { record =>
val tryValue: Try[String] = record.record.value()
val offset: Offset = record.offset
tryValue match {
case Success(value) =>
// Action for successful deserialization
someEffect(value).as(offset)
case Failure(exception) =>
// Possibly log the exception or take alternative action
ZIO.succeed(offset)
}
}
.flattenChunks
.aggregateAsync(Consumer.offsetBatches)
.mapM(_.commit)
.runDrain
.provideSomeLayer(consumer)
2020
Reactive Design: The dark side
Tomek Nurkiewicz: "Reactive Programming, lessons learned"
Andrzej Ludwikowski: "Event Sourcing - what could possibly go wrong?"
Where to start?
https://www.lightbend.com/learn/lightbend-reactive-architecture
2020
@kpciesielski