Slide 1

Slide 1 text

Modernizing Systems with Microservices, Hystrix and RxJava Holger Kraus Javadays Kiev, Nov 4, 2015

Slide 2

Slide 2 text

A typical System

Slide 3

Slide 3 text

The context

Slide 4

Slide 4 text

Current problems > Maintenance is difficult > New features need a lot of time > Very unstable > Outdated technology > Doesn’t scale + frustrated developers :(

Slide 5

Slide 5 text

Current problems > Maintenance is difficult > New features need a lot of time > Very unstable > Outdated technology > Doesn’t scale Microservices FTW ! not yet …

Slide 6

Slide 6 text

Stabilize first!

Slide 7

Slide 7 text

External dependencies here! here! and also here!

Slide 8

Slide 8 text

Cascading Failures https://www.flickr.com/photos/benstassen/2991003141/

Slide 9

Slide 9 text

Stability patterns > Timeouts > Circuit Breaker > Bulkhead … Fail Fast, Steady State, Handshaking, Test Harness, Decoupling Middleware

Slide 10

Slide 10 text

Timeout https://www.flickr.com/photos/55293400@N07/15564061004

Slide 11

Slide 11 text

Bulkheads https://www.flickr.com/photos/10413717@N08/6935206524

Slide 12

Slide 12 text

Ships http://de.wikipedia.org/wiki/RMS_Titanic#/media/File:Titanic_Structure_de.svg

Slide 13

Slide 13 text

Bulkheads and IT > Thread pools > Database connection pools > Instances > Server > Data center

Slide 14

Slide 14 text

Circuit Breaker https://www.flickr.com/photos/leafbug/409950515/

Slide 15

Slide 15 text

Circuit Breaker http://martinfowler.com/bliki/CircuitBreaker.html

Slide 16

Slide 16 text

Hystrix > Library from Netflix > Resilience Library > Command Pattern > Metrics > Dashboard

Slide 17

Slide 17 text

Use Cases let’s pick this one!

Slide 18

Slide 18 text

Search Products 2. find external products 1. search products 3. find internal products 4. return internal + external products

Slide 19

Slide 19 text

Search Products

Slide 20

Slide 20 text

Call without Hystrix cascading failures incoming!

Slide 21

Slide 21 text

Simple Command

Slide 22

Slide 22 text

Execute it!

Slide 23

Slide 23 text

Execute it asynchronously

Slide 24

Slide 24 text

Fallback

Slide 25

Slide 25 text

In case Merchant 2 is down something is missing here

Slide 26

Slide 26 text

The stabilized system

Slide 27

Slide 27 text

Demo

Slide 28

Slide 28 text

And now?

Slide 29

Slide 29 text

Current Problems > Maintenance is difficult > New features need a lot of time > Very unstable => enables further distribution > Outdated technology > Doesn’t scale

Slide 30

Slide 30 text

© 2015 innoQ Deutschland GmbH We need a clear cut! https://www.flickr.com/photos/taefit/8528632756

Slide 31

Slide 31 text

Microservices! but how to get started ????

Slide 32

Slide 32 text

Architectural Decisions

Slide 33

Slide 33 text

Domain Architecture which boxes do we need ? let the monolith guide you!

Slide 34

Slide 34 text

Macro Architecture > Integration > Deployment > Formats > Protocols > Reduce Choices what’s the same for all boxes ? = API + UI = Docker = JSON = HTTP + AMQP = Java, Go Monozon: pick your own!

Slide 35

Slide 35 text

Micro Architecture

Slide 36

Slide 36 text

Migration Path ? pick one [big bang, strangler, wonder]

Slide 37

Slide 37 text

Big Bang a.k.a REVOLUTION only call old monolith meanwhile build new systems: Step 1

Slide 38

Slide 38 text

Big Bang a.k.a REVOLUTION only call new shiny systems Step2 delete this one!

Slide 39

Slide 39 text

Strangler a.k.a EVOLUTION Step 0 your monolith a.k.a „Big Ball of Mud“

Slide 40

Slide 40 text

Strangler a.k.a EVOLUTION Step 1 give your monolith internal structure and interfaces … if possible.

Slide 41

Slide 41 text

Strangler a.k.a EVOLUTION Step 2 - Extract your new Service

Slide 42

Slide 42 text

Strangler a.k.a EVOLUTION Step3 - Extract your new Service

Slide 43

Slide 43 text

Is it really so easy?

Slide 44

Slide 44 text

Time to connect boxes

Slide 45

Slide 45 text

Synchronous vs. Async/Parallel

Slide 46

Slide 46 text

Try this with futures blocking! blocking!

Slide 47

Slide 47 text

Time for RxJava > Reactive Extensions for the JVM > Asynchronous streams > Elements of > Iterator pattern > Observable pattern > Functional programming

Slide 48

Slide 48 text

https://speakerdeck.com/benjchristensen/functional-reactive-programming-with-rxjava-javaone-2013

Slide 49

Slide 49 text

Everything is a stream! https://www.flickr.com/photos/gruesome/3010529489

Slide 50

Slide 50 text

RxJava in one picture https://speakerdeck.com/benjchristensen/functional-reactive-programming-with-rxjava-javaone-2013

Slide 51

Slide 51 text

Creating Observables

Slide 52

Slide 52 text

Transforming with map http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 53

Slide 53 text

map in action

Slide 54

Slide 54 text

Combining with merge http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 55

Slide 55 text

merge in action

Slide 56

Slide 56 text

Combining streams with zip http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 57

Slide 57 text

zip in action

Slide 58

Slide 58 text

Collecting details with flatMap http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 59

Slide 59 text

flatMap in action

Slide 60

Slide 60 text

Why not map?

Slide 61

Slide 61 text

Concurrency

Slide 62

Slide 62 text

Easier with Hystrix

Slide 63

Slide 63 text

Converting into a stream

Slide 64

Slide 64 text

Returning a result

Slide 65

Slide 65 text

Summary > Use Hystrix to stabilize your system! > Use RxJava to increase the amount of async/ parallel processes in an easy way! > Introduce Microservices to get control over your system again! > Have fun :)

Slide 66

Slide 66 text

Thank you! [email protected] Always worth a visit: innoq.com