Get Reactive: Microservices, Programming, and Systems Jeremy Davis Principal Solution Architect, App Dev @argntprgrmr
Why Does Any of This Matter?
Jakob Nielsen 46 years, 3 numbers 0.1 1 10 3 microservicesjourney.com
4 microservicesjourney.com
Reactive is Responsive
Also Tools! there are always tools 6
Reactive Systems/Reactive Programming
Programming, Systems, Both Observable.range(1, 100) .groupBy(n -> n % 2 == 0) .flatMap(g -> { return g.takeWhile(i -> i < 30).toList(); }).filter(l -> !l.isEmpty()).forEach(System.out::println); 8
9 microservicesjourney.com
Reactive Programming Reactive Systems Event Driven Message Driven Embraces realities of data Embraces realities of the network 10 imicroservicesjourney.com
Reactive Systems
Reactive Manifesto 12
Responsive because people get bored dependability • maintained under failure (resilience) • maintained under load (elasticity) • 13
Resilient things fail The system must be responsive in the face of failure must be designed for not added in • self-healing, full recovery • replication • isolation and containment • delegation • 14 microservicesjourney.com
Elastic everything changes A System must stay responsive under various workloads scales up and down • no contention points or bottlenecks • replicable/shardable components • provide relevant live performance measures • 15
Message Driven asynchronous communication asynchronous, non-blocking • location transparency • failures delegated as messages • back pressure • 16
Reactive Microservices
Why? the basics “The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API . These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies. “ — Martin Fowler http://martinfowler.com/articles/microservices.html 18
Toolkits, Libraries, Frameworks
20 microservicesjourney.com
Reactive Programming
ReactiveX An API for asynchronous programming with observable streams 22 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
RxJava as opposed to traditional programming Traditional RxJava • Call a method • Create a method that does something useful • Store the return value in a variable with the return values of an asynchronous call • Do something useful with the variable • Define the asynchronous call ( Observable ) • Attach an observer to the Observable by subscribing • Do other stuff until the call returns and the Observable begins to operate on the results 23 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
rx.Observable() Observable.range(1, 100) .groupBy(n -> n % 2 == 0) .flatMap(g -> { return g.toList(); }).forEach(System.out::println); 24
Observer Pattern like the Gang of Four pattern with onCompleted() and onError() 25 microservicesjourney.com
rx.Observable() 26
Operators (marbles) Insert copy 27 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
28
Summary: rxJava all about the Observables Observable • Operators • Marbles • Learning curve • 29
One Rule: “Don’t mutate state outside of the function”
Reactive Streams
Reactive Streams a standard for asynchronous stream processing that isn’t for end users • Standard • Interoperability layer • no operators • java.util.concurrent.Flow • Github • JavaScript • Lightbend, Netflix, Pivotal, Red Hat 32 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
Actor Mailbox Actor Actor Mailbox Mailbox Actor Actor Mailbox Mailbox 33 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
Actor Mailbox akka://default/user/$a#114635109 Actor Mailbox akka://default/user/$a#114635173 34 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
35 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
Summary: akka its all about the actor model Actor Model • Messaging • Addressing • Steams, Web, others • Reactive end to end • 36
a toolkit for building reactive applications on the JVM COLUMN HEADING ALL CAPS Event Loop Vertices Event Bus 37 INSERT DESIGNATOR, IF NEEDED (EDIT ON MASTER SLIDE)
single threaded event loop 38
Cardinal Rule: “Don’t Block the Event Loop”
its all about verticles 40
messages 41
JsonObject 42
Summary: Eclipse Vert.x its all about reactive Reactive from end to end • Json • Event Loop • Messaging • rxJava built in • Polyglot • 43
Project Reactor and WebFlux 44
45
Summary: Spring Reactor its hidden Flux • Mono • WebFlux • Reactive Streams • 46
Links General Books: https://info.lightbend.com/COLL-20XX-Designing-Reactive-Systems_RES-LP.html Webinars : https://www.lightbend.com/blog/akka-revealed-jvm-architects-journey-from-resilient-actors- to-scalable-clusters https://www.lightbend.com/blog/using-the-actor-model-with-domain-driven-design-ddd-in- reactive-systems-with-vaughn-vernon Blogs: https://developer.lightbend.com/blog/2017-08-10-atotm-akka-messaging-part-1/index.html https://developer.lightbend.com/blog/2017-11-01-atotm-akka-messaging-part-2/index.html 47
Links Vert.x Tutorials: http://vertx.io/blog/posts/introduction-to-vertx.html http://escoffier.me/vertx-hol/ Books: http://vertx.io/docs/guide-for-java-devs/ https://developers.redhat.com/promotions/building-reactive-microservices-in-java/ Presentations: https://www.youtube.com/channel/UCGN6L3tRhs92Uer3c6VxOSA 48
Links RxJava Books: http://shop.oreilly.com/product/0636920042228.do Code: https://github.com/ReactiveX/RxJava https://github.com/jhusain/learnrxjava Presentations: GOTO 2013 • Functional Reactive Programming with RxJava • Ben Christensen 49
Links Spring Reactor/WebFlux Blogs: https://spring.io/blog/2016/06/07/notes-on-reactive-programming-part-i-the-reactive- landscape Presentations: https://www.youtube.com/watch?v=zVNIZXf4BG8 50
Thank You! plus.google.com/+RedHat facebook.com/redhatinc linkedin.com/company/red-hat twitter.com/RedHatNews youtube.com/user/RedHatVideos
Recommend
More recommend