Going Reactive: Building Better Microservices; rob harrop
-
Upload
spring-io -
Category
Technology
-
view
924 -
download
1
Transcript of Going Reactive: Building Better Microservices; rob harrop
![Page 1: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/1.jpg)
Going ReactiveRob Harrop
![Page 2: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/2.jpg)
Who am I?
▸ CEO @ Skipjaq▸ ML-driven performance optimisation
▸ Co-founder of SpringSource
▸ Once upon a time I…▸ Contributed to Spring Framework
▸ Wrote a book about Spring
▸ Talked a lot about Spring
![Page 3: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/3.jpg)
Who am I?
▸ I’m on Twitter: ▸ @robertharrop
▸ I’m on Github/Gitlab: ▸ github.com/robharrop
▸ gitlab.com/rdh
▸ gitlab.com/skipjaq/hotspotmon
▸ I write about maths, modelling and performance ▸ https://robharrop.github.io
If you have questions after the session, {grab, tweet} me.
![Page 4: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/4.jpg)
Agenda
![Page 5: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/5.jpg)
Principles & Practice
![Page 6: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/6.jpg)
Why Reactive?
![Page 7: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/7.jpg)
Architecture is Fractal
![Page 8: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/8.jpg)
Reactive Systems
![Page 9: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/9.jpg)
ELKInflux Graphite
Publishers
Publish
Publishers
JVM JVM JVM
Systems as Streams
Hotspot MonSubscriber Publisher
Subscribe
![Page 10: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/10.jpg)
Reactive Subsystems
![Page 11: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/11.jpg)
JVM JVM
Subsystems as Streams
JVM Stat
Sampler
Clock
Repository
WebInflux
InfluxDB Browser
JVM
![Page 12: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/12.jpg)
Reactive Objects
![Page 13: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/13.jpg)
JVM
Total compiles
OSR compiles
100 83 62
12 8 5
Subscriber
Subscriber
Metrics as Streams
![Page 14: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/14.jpg)
JVM as Streams
Host JVM1359
JVM459
JVM1976
![Page 15: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/15.jpg)
Principles
![Page 16: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/16.jpg)
Reactive Manifesto
▸ Resilient▸ Responsive▸ Elastic▸ Message-driven
![Page 17: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/17.jpg)
Resilient
![Page 18: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/18.jpg)
Back Pressure
Total Compiles
Influx Publisher
Influx HTTP Client
q n
∞ m
When n>m we have back pressure - an upstream publisher is too quick for a downstream publisher
![Page 19: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/19.jpg)
Responsive
![Page 20: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/20.jpg)
Asynchrony
Publisher Subscriber
Q
U
E
UE
1
2
3
1
2
![Page 21: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/21.jpg)
Message-driven
![Page 22: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/22.jpg)
Reactive Streams
![Page 23: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/23.jpg)
public interface Publisher<T> {
public void subscribe(Subscriber<? super T> s);}
![Page 24: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/24.jpg)
public interface Subscriber<T> { public void onSubscribe(Subscription s);
public void onNext(T t);
public void onError(Throwable t);
public void onComplete();}
![Page 25: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/25.jpg)
public interface Subscription { public void request(long n);
public void cancel();}
![Page 26: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/26.jpg)
public interface Processor<T, R> extends Subscriber<T>, Publisher<R> {
}
![Page 27: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/27.jpg)
Project Reactor
▸ Reactive Streams defines a programming model
▸ Project Reactor provides an implementation of that model
▸ Flux<T> is a zero-to-many Publisher
▸ Mono<T> is a zero-or-one Publisher
▸ Reactor manages back pressure and asynch processing
![Page 28: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/28.jpg)
Practice
![Page 29: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/29.jpg)
Hotspotmon
![Page 30: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/30.jpg)
Summary
▸ Reactive is a fractal model
▸ Publishers capture outputs from systems
▸ Subscribers capture interaction with those outputs
▸ Async, isolation and capacity management are built-in
▸ Reactive Streams captures the core contracts of a Reactive system
▸ Project Reactor provides a sophisticated implementation of Reactive Streams
![Page 31: Going Reactive: Building Better Microservices; rob harrop](https://reader034.fdocuments.net/reader034/viewer/2022042517/586fdb501a28ab18428b6077/html5/thumbnails/31.jpg)
Q&A