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

Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

Wir lösen das – persönlich!

Modernizing systems with Microservices, Hystrix and RxJava

Holger Kraus, Arne Landwehr

Berlin Expert Days, Berlin, Sep 18, 2015

Page 2: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

A typical system

Page 3: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

The context

Page 4: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 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 :(

Page 5: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Stabilize first!

Page 6: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

External dependencies

here!

here!

and also here!

Page 7: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Cascading Failures

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

Page 8: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Stability patterns‣ Timeouts

‣ Circuit Breaker

‣ Bulkheads

… Fail Fast, Steady State , Handshaking, Test Harness, Decoupling Middleware

Page 9: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Timeout

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

Page 10: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Bulkheads

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

Page 11: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Ships

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

Page 12: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Bulkheads and IT

‣ Thread pools

‣ Database connection pools

‣ Instances

‣ Server

‣ Data center

Page 13: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Circuit Breaker

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

Page 14: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Circuit Breaker

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

Page 15: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

‣ Library from Netflix

‣ Resilience Library

‣ Command Pattern

‣ Metrics

‣ Dashboard

Hystrix

Page 16: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Use Cases

let’s pick this one!

Page 17: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Search Products

2. find external products

1. search products

3. find internal products

4. return internal + external products

Page 18: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Search Products

Page 19: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Call without Hystrix

cascading failures incoming!

Page 20: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Simple Command

Page 21: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Execute it!

Page 22: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Execute it asynchronously

Page 23: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Fallback

Page 24: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

In case Merchant 2 is down:

something is missing here

Page 25: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

The stabilized system

Page 26: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Demo

Page 27: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

And now?

Page 28: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 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

Page 29: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

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

Page 30: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 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

Page 31: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

We need a clear cut!https://www.flickr.com/photos/taefit/8528632756

Page 32: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Our mission:

Creating smaller systems that are

‣ understandable

‣ enhanceable

‣ have clear boundaries and responsibilities

‣ allow technological diversity

Page 33: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

The typical cut

Page 34: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Vertical Services, one UI

Page 35: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Self contained Systems

Page 36: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Micro architecture

‣ Separate (redundant) persistence

‣ Internal, separate logic

‣ Domain models & implementation strategies

‣ Separate UI

‣ Separate development and evolution

Page 37: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 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

Page 38: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

From internal structure

Page 39: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

To autonomous systems

Page 40: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Ask the monolith

‣ identify Bounded Contexts

‣ define boundaries explicitly

‣ The experience with the monolith helps to create clear system boundaries

Page 41: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Connect!

https://www.flickr.com/photos/npobre/8189066572

Page 42: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Macro architecture

‣ defines standards across systems

‣ UI integration

‣ communication protocols

‣ representation formats

‣ data redundancy

‣ logging, monitoring, security

Page 43: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Smart endpoints, dump pipes!

http://martinfowler.com/articles/microservices.html

Martin Fowler, James Lewis

Page 44: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 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

Page 45: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Connecting data

Page 46: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Synchronous vs. Asynchronous

Page 47: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Time for RxJava!

‣ Reactive Extensions for the JVM

‣ Asynchronous streams

‣ Elements of

‣ Iterator patter

‣ Observable pattern

‣ Functional programming

Page 48: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

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

Page 49: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

RxJava in one picture

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

Page 50: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Create streams

Doesn’t work

for us!!!

Page 51: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Better

Page 52: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Converting into a stream

Page 53: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Transforming with map

http://reactivex.io/RxJava/javadoc/rx/Observable.html

Page 54: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

map in action

Page 55: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Combining with merge

http://reactivex.io/RxJava/javadoc/rx/Observable.html

Page 56: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

merge in action

Page 57: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Collecting details with flatMap

http://reactivex.io/RxJava/javadoc/rx/Observable.html

Page 58: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Combining streams with zip

http://reactivex.io/RxJava/javadoc/rx/Observable.html

Page 59: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

flatMap and zip in action

Page 60: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Blocking streams

Page 61: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Systems connected

Page 62: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

How could you start?https://www.flickr.com/photos/epemsl/8790814488

Page 63: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Our goal was to make you curious!

Page 64: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 2015 innoQ Deutschland GmbH

Find your own way!

Page 65: Modernizing systems with Microservices, Hystrix and RxJavabed-con.org/2015/files/slides/MicroservicesHystrixRxJava... · 2016-01-15 · Modernizing systems with Microservices, Hystrix

© 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 :)