(Micro-)service collaboration
WJAX, Munic, 08th of November 2017
mail@bernd-ruecker.com | @berndruecker
With thoughts from http://flowing.io
@berndruecker | @martinschimak
Simplified example:
dash button
Photo by 0xF2, available under Creative Commons BY-ND 2.0
license. https://www.flickr.com/photos/0xf2/29873149904/
Basic idea of dedicated, autonomous (micro-) services
Checkout
Payment
Inventory
Shipment
Dedicated Application Processes
Dedicated Persistence Backends
Dedicated Development Teams
But: A lot of them…
Checkout
Payment
Inventory
Shipment
The complexity
moves to the
collaboration of the
services
Distributed systems
My plan for today:
Sync -> async -> beyond request/response
(just a teaser – mostly live coding)
Live hacking
Circuit
Breaker
Photo by CITYEDV, available under Creative Commons CC0 1.0 license.
Photo by Pearson Scott Foresman, available under Public Domain license.
Gracefully degrade
instead of
epic fails!
Ask: who is responsible to deal with problems?
Order
Credit
Card
Payment
A good service cares about his sh.. – especially
failures.
Sometimes it is better to introduce (persistent) state
and handle it yourself.
Persist thing with
Entity, Actor, …
State machine or
workflow engine
DIY
Output
Mgmt
PDF
created
How to
implement long-
running services?
State machines
or workflow
engines
CADENCE
Baker
Live hacking
But my customer wants to have the ticket right
away!
Finally I get my boarding pass!
This can also take
days to complete now!
Fallbacks make
your system
more resilient
Synchronous request/response
+ Easy to do
- Availability erosion, latency creep
~ Requires circuit breaker, retry,
fallback, suspension, …
But: Beware of DOS attacks by retries!
Synchronous communication
is the crystal meth of
distributed programming
Todd Montgomery and Martin Thompson
in “How did we end up here” at GOTO Chicago 2015
Better asynchronous communication?
That typically means: messaging
systems.
Operating messaging systems is hard.
You could also ask for work
Get work
Complete/Fail
Work
Distribution
Service
Live hacking
Design
for
failure!
2356143672_f5f88797d5_b.jpg
Photo by GalaticWanderlust, available under Creative Commons BY 2.0 license.
In general, application developers simply do
not implement large scalable applications
assuming distributed transactions. When
they attempt to use distributed transactions,
the projects founder because the
performance costs and fragility make them
impractical. Natural selection kicks in…
Business
transactions
can work
without
two phase
commit!
Photo by Gerhard51, available under Creative Commons CC0 1.0 license.
The world beyond request/response
Request/Response: temporally coupled services
Checkout
Payment
Inventory
Shipment
„The button blinks green
if we can ship the item
within 24 hours!“
Request Response
Events: temporal decoupling with read models
Checkout
Payment
Inventory
Shipment
„The button blinks green
if we can ship the item
within 24 hours!“
Events are facts about
what happened (in the past)
Good
Fetched
Good
Stored
Read
Model
Events can decrease coupling*
*e.g. decentral data-management, read models, …
Events: peer-to-peer event choreographies
Checkout
Payment
Inventory
Shipment
Order
placed
Payment
received
Good
shipped
„When the button is pressed, an
order is placed - and fulfilled!“
Good
fetched
Events: peer-to-peer event choreographies
Please fetch
the goods
before waiting
for payment
Some
customers can
pay via invoice
…
Checkout
Payment
Inventory
Shipment
Good
fetched
Order
placed
Payment
received
Good
shipped
Events can increase coupling*
*e.g. complex peer-to-peer event chains
Extract the end-to-end responsibility
Order
Checkout
Payment
Inventory
Shipment
Order
placed
Retrieve
payment
Commands have an
intent about what needs
to happen in the future
Please fetch
the goods
before waiting
for payment
Some
customers can
pay via invoice
Payment
received
Retrieve
payment
Workflows live inside service boundaries
Example
InventoryPaymentOrder ShippingCheckout Monitor
https://github.com/flowing/flowing-retail/
Human
Tasks
Live hacking
Wrap-up
# Understand complexity of distributed systems
Sync/async, request/response, event-driven
# Know strategies and tools to handle it
e.g.Circuit breaker (Hystrix)
State machine for visual flow, wait, timeout,
retry and compensation (Camunda, Zeebe)
Thank you!
Code:
https://github.com/berndruecker
Slides:
https://bernd-ruecker.com
Blog:
https://blog.bernd-ruecker.com
Feedback:
https://bernd-ruecker.com/feedback
With thoughts from http://flowing.io
@berndruecker | @martinschimak
Images licensed from iStock
no attribution required
All icons licensed from Noun Project
no attribution required
Own photos

Collaboration of (micro-)services