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