Slide 1

Slide 1 text

Wir lösen das – persönlich! Modernizing systems with Microservices, Hystrix and RxJava Holger Kraus, Arne Landwehr Berlin Expert Days, Berlin, Sep 18, 2015

Slide 2

Slide 2 text

© 2015 innoQ Deutschland GmbH A typical system

Slide 3

Slide 3 text

© 2015 innoQ Deutschland GmbH The context

Slide 4

Slide 4 text

© 2015 innoQ Deutschland GmbH 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

© 2015 innoQ Deutschland GmbH Stabilize first!

Slide 6

Slide 6 text

© 2015 innoQ Deutschland GmbH External dependencies here! here! and also here!

Slide 7

Slide 7 text

© 2015 innoQ Deutschland GmbH Cascading Failures https://www.flickr.com/photos/benstassen/2991003141/

Slide 8

Slide 8 text

© 2015 innoQ Deutschland GmbH Stability patterns ‣ Timeouts ‣ Circuit Breaker ‣ Bulkheads 
 … Fail Fast, Steady State , Handshaking, Test Harness, Decoupling Middleware

Slide 9

Slide 9 text

© 2015 innoQ Deutschland GmbH Timeout https://www.flickr.com/photos/55293400@N07/15564061004

Slide 10

Slide 10 text

© 2015 innoQ Deutschland GmbH Bulkheads https://www.flickr.com/photos/10413717@N08/6935206524

Slide 11

Slide 11 text

© 2015 innoQ Deutschland GmbH Ships http://de.wikipedia.org/wiki/RMS_Titanic#/media/File:Titanic_Structure_de.svg

Slide 12

Slide 12 text

© 2015 innoQ Deutschland GmbH Bulkheads and IT ‣ Thread pools ‣ Database connection pools ‣ Instances ‣ Server ‣ Data center

Slide 13

Slide 13 text

© 2015 innoQ Deutschland GmbH Circuit Breaker https://www.flickr.com/photos/leafbug/409950515/

Slide 14

Slide 14 text

© 2015 innoQ Deutschland GmbH Circuit Breaker http://martinfowler.com/bliki/CircuitBreaker.html

Slide 15

Slide 15 text

© 2015 innoQ Deutschland GmbH ‣ Library from Netflix ‣ Resilience Library ‣ Command Pattern ‣ Metrics ‣ Dashboard Hystrix

Slide 16

Slide 16 text

© 2015 innoQ Deutschland GmbH Use Cases let’s pick this one!

Slide 17

Slide 17 text

© 2015 innoQ Deutschland GmbH Search Products 2. find external products 1. search products 3. find internal products 4. return internal + external products

Slide 18

Slide 18 text

© 2015 innoQ Deutschland GmbH Search Products

Slide 19

Slide 19 text

© 2015 innoQ Deutschland GmbH Call without Hystrix cascading failures incoming!

Slide 20

Slide 20 text

© 2015 innoQ Deutschland GmbH Simple Command

Slide 21

Slide 21 text

© 2015 innoQ Deutschland GmbH Execute it!

Slide 22

Slide 22 text

© 2015 innoQ Deutschland GmbH Execute it asynchronously

Slide 23

Slide 23 text

© 2015 innoQ Deutschland GmbH Fallback

Slide 24

Slide 24 text

© 2015 innoQ Deutschland GmbH In case Merchant 2 is down: something is missing here

Slide 25

Slide 25 text

© 2015 innoQ Deutschland GmbH The stabilized system

Slide 26

Slide 26 text

© 2015 innoQ Deutschland GmbH Demo

Slide 27

Slide 27 text

© 2015 innoQ Deutschland GmbH And now?

Slide 28

Slide 28 text

© 2015 innoQ Deutschland GmbH Current problems ‣ Maintenance is difficult ‣ New features need a lot of time ‣ Very unstable => enables further distribution ‣ Outdated technology ‣ Doesn’t scale

Slide 29

Slide 29 text

© 2015 innoQ Deutschland GmbH https://www.flickr.com/photos/donmaedi/116013352

Slide 30

Slide 30 text

© 2015 innoQ Deutschland GmbH Monozon is a typical Monolith ‣ hidden dependencies ‣ module boundaries are not clear ‣ distributed business processes ‣ just one technical platform ‣ Everything depends on everything

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

© 2015 innoQ Deutschland GmbH Our mission: Creating smaller systems that are ‣ understandable ‣ enhanceable ‣ have clear boundaries and responsibilities ‣ allow technological diversity

Slide 33

Slide 33 text

© 2015 innoQ Deutschland GmbH The typical cut

Slide 34

Slide 34 text

© 2015 innoQ Deutschland GmbH Vertical Services, one UI

Slide 35

Slide 35 text

© 2015 innoQ Deutschland GmbH Self contained Systems

Slide 36

Slide 36 text

© 2015 innoQ Deutschland GmbH Micro architecture ‣ Separate (redundant) persistence ‣ Internal, separate logic ‣ Domain models & implementation strategies ‣ Separate UI ‣ Separate development and evolution

Slide 37

Slide 37 text

© 2015 innoQ Deutschland GmbH Domain architecture ‣ System boundaries reflect business dependencies ‣ defines who is responsible for which data ‣ follows the principle of ‣ loose coupling ‣ high cohesion

Slide 38

Slide 38 text

© 2015 innoQ Deutschland GmbH From internal structure

Slide 39

Slide 39 text

© 2015 innoQ Deutschland GmbH To autonomous systems

Slide 40

Slide 40 text

© 2015 innoQ Deutschland GmbH Ask the monolith ‣ identify Bounded Contexts ‣ define boundaries explicitly ‣ The experience with the monolith helps to create clear system boundaries

Slide 41

Slide 41 text

© 2015 innoQ Deutschland GmbH Connect! https://www.flickr.com/photos/npobre/8189066572

Slide 42

Slide 42 text

© 2015 innoQ Deutschland GmbH Macro architecture ‣ defines standards across systems ‣ UI integration ‣ communication protocols ‣ representation formats ‣ data redundancy ‣ logging, monitoring, security

Slide 43

Slide 43 text

© 2015 innoQ Deutschland GmbH Smart endpoints, dump pipes! http://martinfowler.com/articles/microservices.html Martin Fowler, James Lewis

Slide 44

Slide 44 text

© 2015 innoQ Deutschland GmbH Consequences ‣ Transactions contexts are bound to just one system ‣ Data should be just changed by the systems that are responsible for it ‣ Processes need Data that are spread over various systems

Slide 45

Slide 45 text

© 2015 innoQ Deutschland GmbH Connecting data

Slide 46

Slide 46 text

© 2015 innoQ Deutschland GmbH Synchronous vs. Asynchronous

Slide 47

Slide 47 text

© 2015 innoQ Deutschland GmbH Time for RxJava! ‣ Reactive Extensions for the JVM ‣ Asynchronous streams ‣ Elements of ‣ Iterator patter ‣ Observable pattern ‣ Functional programming

Slide 48

Slide 48 text

© 2015 innoQ Deutschland GmbH https://speakerdeck.com/benjchristensen/functional-reactive-programming-with-rxjava-javaone-2013

Slide 49

Slide 49 text

© 2015 innoQ Deutschland GmbH RxJava in one picture https://speakerdeck.com/benjchristensen/functional-reactive-programming-with-rxjava-javaone-2013

Slide 50

Slide 50 text

© 2015 innoQ Deutschland GmbH Create streams Doesn’t work for us!!!

Slide 51

Slide 51 text

© 2015 innoQ Deutschland GmbH Better

Slide 52

Slide 52 text

© 2015 innoQ Deutschland GmbH Converting into a stream

Slide 53

Slide 53 text

© 2015 innoQ Deutschland GmbH Transforming with map http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 54

Slide 54 text

© 2015 innoQ Deutschland GmbH map in action

Slide 55

Slide 55 text

© 2015 innoQ Deutschland GmbH Combining with merge http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 56

Slide 56 text

© 2015 innoQ Deutschland GmbH merge in action

Slide 57

Slide 57 text

© 2015 innoQ Deutschland GmbH Collecting details with flatMap http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 58

Slide 58 text

© 2015 innoQ Deutschland GmbH Combining streams with zip http://reactivex.io/RxJava/javadoc/rx/Observable.html

Slide 59

Slide 59 text

© 2015 innoQ Deutschland GmbH flatMap and zip in action

Slide 60

Slide 60 text

© 2015 innoQ Deutschland GmbH Blocking streams

Slide 61

Slide 61 text

© 2015 innoQ Deutschland GmbH Systems connected

Slide 62

Slide 62 text

© 2015 innoQ Deutschland GmbH How could you start? https://www.flickr.com/photos/epemsl/8790814488

Slide 63

Slide 63 text

© 2015 innoQ Deutschland GmbH Our goal was to make you curious!

Slide 64

Slide 64 text

© 2015 innoQ Deutschland GmbH Find your own way!

Slide 65

Slide 65 text

© 2015 innoQ Deutschland GmbH 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

© 2015 innoQ Deutschland GmbH Thank you! [email protected] [email protected]