3 common pitfalls in microservice integration and how to avoid … · 2018-11-05 ·...
TRANSCRIPT
3 Common Pitfalls inMicroservice Integration andHow to Avoid Them
@berndruecker
Berlin, Germany
[email protected]@berndruecker
Bernd RueckerCo-founder and Developer Advocate ofCamunda
REST, SOAP,Cloud, Saas,
Microservices, SCS, FaaS, Serverless,
…
Distributed systems
https://www.infoworld.com/article/3254777/application-development/3-common-pitfalls-of-microservices-integrationand-how-to-avoid-them.html
Distributed systems
Challenges of asynchronicity
DistributedTransactions
Communication is complex
SomeService
SomeService
SomeService
SomeService
SomeService
SomeService
SomeService
Failure will happen. Accept it!
But keep it local! Be resilient.
Let‘s start with a simple example
CreditCard
Payment
REST
Live hacking
https://github.com/berndruecker/flowing-retail
Circuit Breaker
Photo by CITYEDV, available under Creative Commons CC0 1.0 license.
Fail fastis important
Fail fastis important
but not enough!
Photo by Tookapic, available under Creative Commons CC0 1.0 license.
„There was an errorwhile sending your
boarding pass“
Check-in
Web-UI
Me
Current situation
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Current situation
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Current situation
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Current situation
Circuit breaker
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Current situation – the bad part
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Current situation – the bad part
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Current situation – the bad part
StatefulRetry
We are having some technicaldifficulties and cannot present you
your boarding pass right away.
But we do actively retry ourselves, so lean back, relax and we will send it
on time.
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Possible situation – much better!
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Possible situation – much better!
StatefulRetry
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
StatefulRetry
Possible situation – much better!
The failurenever leavesthis scope!
Persist thing(Entity, Document, Actor, …)
State machine orworkflow engine
Typicalconcerns
DIY = effort, accidentalcomplexity
Complex, proprietary, heavyweight, slow,
don‘t scale,developer adverse
Scheduling, Versioning, operating, visibility, scalability, …
Handling State
Workflow engines, state machines
It is
relevantin modern
architectures
CADENCE
Silicon valleyhas recognized
Workflow engines, state machines
CADENCEWorkflow engines, state machines
CADENCE
also at scaleWorkflow engines, state machines
CADENCE
for todays demo
Workflow engines, state machines
Live hacking
https://github.com/berndruecker/flowing-retail
Payment
Now you have a state machine!
CreditCardREST
has to implement
Retryhas to implement
Idempotency
Client Service Provider
We are processing your payment.Do not leave this page.
And for god sake – do not reload!
It is a businessproblemanyway!
We are processing your payment.Do not leave this page.
And for god sake – do not reload!
It is a businessproblemanyway!
We are currently processing your request. Don‘t worry, it will happen safely –
even if you loose connection. Feel free to reload this page any time!
Requirement: Idempotency of services!
Photo by pixabay, available under Creative Commons CC0 1.0 license.
Requirement: Idempotency of services!
Photo by Chr.Späth, available under Public Domain.
Distributed systems introduce complexity you have to tackle!
CreditCard
PaymentREST
Distributedsystems
It is impossible todifferentiate certain
failure scenarios.
Independant ofcommunication style!
Service Provider
Client
Distributed systems introduce complexity you have to tackle!
CreditCard
PaymentREST
Distributed systems introduce complexity you have to tackle!
CreditCard
PaymentREST
BPMNBusiness Process
Model and Notation
ISO Standard
BPMNExecutableand mature Easy to
understand*
Widespread
*(for Biz, Dev, and Ops)
ProperOperations
Visibility + Context
Compare to e.g. Step Functions
Workflows live withinservice boundaries
CreditCard
PaymentREST
Check-in
Barcode Generato
r
Web-UI
Me
Output Mgmt
Workflows live within service boundaries
Check-in
Barcode Generato
r
Web-UI
Me
Output Mgmt
Workflows live within service boundaries
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
generateBoardingPass
HTTP 200 OK
HTTP 202 ACCEPTED
Check-in
Happy case: Synchronous responseOtherwise: asynchronous
„The customer wants a synchronous response“
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
„Eh – no!“
Synchronous communicationis the crystal meth of
distributed programming
Todd Montgomery and Martin Thompson in “How did we end up here” at GOTO Chicago 2015
Challenges of asynchronicity
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Asynchronous communication
You need tomonitor timeouts
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Remember…
The failurenever leavesthis scope!
Workflow…
Workflow…
has to implement
Timeout, Retryhas to implement
Idempotency
Client Service Provider
Who uses a message bus?
Who has no problemsoperating a message bus?
Dead messages | No context | Inaccesible payload | Hard to redeliver | Home-grown message hospitals | …
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Avoids thundering herds
Photo by Gopal Vijayaraghavan, available under Creative Commons BY 2.0 license.
Photo by Gopal Vijayaraghavan, available under Creative Commons BY 2.0 license.
https://aws.amazon.com/de/message/5467D2/
DistributedTransactionsDistributed
Transactions
Distributedsystems
Pat Helland
Grown-Ups Don’t Use Distributed Transactions
“
Distributed Systems Guru Worked at Amazon, Microsoft & Salesforce
Distributed transactions using compensation *
Compensation
Eventual consistency
Temporarilyinconsistent state
But onlytemporarily!
Live hacking
https://github.com/berndruecker/flowing-retail
has to implement
Timeout, Retry, Compensation
has to offer
Compensationhas to implement
Idempotency
Client Service Provider
has to implement
Timeout, Retry, Compensation
has to offer
Compensationhas to implement
Idempotency
Client Service ProviderDon‘t forgetabout state
Event-driven example also available
InventoryPaymentOrder ShippingCheckout Monitor
https://github.com/flowing/flowing-retail/
Human Tasks
H2 H2
Workflows live inside service boundaries
Sales-Order & Order-Fulfillment
via Camunda
for every order worldwide
(Q2 2017: 22,2 Mio)
# Be aware of complexity of distributed systems# Know strategies and tools to handle ite.g. Circuit breaker (Hystrix)
Workflow engine for stateful retry, waiting, timeout and compensation (Camunda)
Thank you!
[email protected]@berndruecker
https://berndruecker.io
https://medium.com/berndruecker
https://github.com/berndruecker
https://www.infoq.com/articles/events-workflow-automation
Contact:
Slides:
Blog:
Code:
https://www.infoworld.com/article/3254777/application-development/3-common-pitfalls-of-microservices-integrationand-how-to-avoid-them.html
https://thenewstack.io/5-workflow-automation-use-cases-you-might-not-have-considered/