Reactive Manifesto
6 years later
Krzysztof Ciesielski
@kpciesielski
Reactive Manifesto
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.
Reactive
Another buzzword?
Has it got adapter like "Microservices"?
Or rather ended up like "BigData"?
versus
Reactive Programming
Reactive System Design
Main goal of the Manifesto
means:
- Microservices
- Message-driven / Event-driven architecture
- Stream processing
- Autoscaling
- Reactive programming
Reactive System Design
microservices
scalability
reacting to changing load = elastic)
failure isolation (resilient)
simpler deployments
better maintainability
Communication: asynchronous, often non-blocking
Reactive System Design
message-driven
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.
Reactive System Design
streaming
Samza, Spark Streaming, Flink, AWS Kinesis
Development powered by Machine Learning
Why reactive?
elastic, fault-tolerant (resilience)
"reacting to changes"
Reactive System Design
autoscaling
DevOps/Cloud explosion
Kubernetes, AWS (Fargate), sophisticated monitoring and alerting (like VictorOps)
Reactive System Design
Practices and tools for building code which is:
- asynchronous, nonblocking
- without explicit coordination between components
- declarative: expressing high-level intentions instead of direct instructions
Describing processing logic, not flow control.
Reactive Programming
Declarative code
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/
Reactive Programming
Future[T] / scalaz Task[T]
Actor Model
RxJava
Vert.x
2014
What is happening in the JVM ecosystem
Reactive Programming
Reactive Streams
Akka Streams
scalaz-stream
Apache Kafka 0.8.1
2014
Reactive Programming
What is happening in the JVM ecosystem
Vaughn Vernon
Reactive Messaging Patterns with the Actor Model
Reactive Programming
2015
Work Pulling (Akka)
Source: https://redsigil.weebly.com/home/akka-work-pulling-pattern-and-some-background
Reactive Programming
Project Reactor (Java)
Source: https://speakerdeck.com/simonbasle/projectreactor-dot-io-reactor3-intro
Reactive Programming
2015
Source: https://speakerdeck.com/simonbasle/projectreactor-dot-io-reactor3-intro
Reactive Programming
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/
Reactive Programming
2016
Akka Persistence, Streams + Alpakka
Kafka 2.3
RxJava
Vert.x
Functional Reactive Programming (FRP)
Cats-Effect, Monix, ZIO
Reactive Programming
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
Reactive Programming
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
Reactive Programming
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 Programming
Reactive Design: The dark side
- Entry threshold
- Debugging
- Orchestration infrastructure
- Observability: Logging, monitoring, tracing
- Testing
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
Reactive Manifesto
2020
Thank You!
@kpciesielski
Reactive Manifesto 6 years later
By Krzysztof Ciesielski
Reactive Manifesto 6 years later
Do you remember how the buzzword "reactive" emerged? In this talk, we will briefly go through its history, then we will examine what it really means today in the context of the current state of the Scala ecosystem. We will compare reactive programming with reactive system design and try to conclude whether the Manifesto is still valid and important.
- 299