Microservice Integration and How to Avoid Them @berndruecker Bernd - - PowerPoint PPT Presentation
Microservice Integration and How to Avoid Them @berndruecker Bernd - - PowerPoint PPT Presentation
3 Common Pitfalls in Microservice Integration and How to Avoid Them @berndruecker Bernd Ruecker Co-founder and Developer Advocate of Camunda Berlin, Germany bernd.ruecker@camunda.com @berndruecker REST, SOAP, Cloud, Saas, Microservices,
Berlin, Germany
bernd.ruecker@camunda.com @berndruecker
Bernd Ruecker
Co-founder and Developer Advocate of Camunda
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 Distributed T ransactions Communication is complex
Some Service Some Service Some Service Some Service Some Service Some Service Some Service
Failure will happen. Accept it! But keep it local! Be resilient.
Let‘s start with a simple example
Credit Card Payment
REST
Live hacking
https://github.com/berndruecker/flowing-retail
Circuit Breaker
Photo by CITYEDV, available under Creative Commons CC0 1.0 license.
Fai ail f l fast is important
Fai ail f l fast is important but not enough!
Photo by Tookapic, available under Creative Commons CC0 1.0 license.
„There was an error while 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
Stateful Retry
We are having some technical difficulties and cannot present you your boarding pass right away. But we do actively retry ourselves, so lean back, relax and we will send it
- n 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!
Stateful Retry
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Stateful Retry
Possible situation – much better!
The failure never leaves this scope!
Persist thing (Entity, Document, Actor, …) State machine or workflow engine T ypical concerns DIY = effort, accidental complexity Complex, proprietary, heavyweight, slow, don‘t scale, developer adverse
Scheduling, Versioning,
- perating, visibility,
scalability, …
Handling State
Workflow engines, state machines
It is
relevant
in modern architectures
CADENCE
Silicon valley has recognized
Workflow engines, state machines
CADENCE
Workflow engines, state machines
CADENCE
also at scale
Workflow 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!
Credit Card
REST
has to implement
Retry
has 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 business problem anyway!
We are processing your payment. Do not leave this page. And for god sake – do not reload!
It is a business problem anyway!
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!
Credit Card Payment
REST
Distributed systems
It is impossible to differentiate certain failure scenarios.
Independant of communication style!
Service Provider Client
Distributed systems introduce complexity you have to tackle!
Credit Card Payment
REST
Distributed systems introduce complexity you have to tackle!
Credit Card Payment
REST
BPMN
Business Process Model and Notation ISO Standard
BPMN
Executable and mature Easy to understand* Widespread
*(for Biz, Dev, and Ops)
Proper Operations
Visibility + Context
Compare to e.g. Step Functions
Workflows live within service boundaries
Credit Card Payment
REST
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 response Otherwise: asynchronous
„The customer wants a synchronous response“
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
„Eh – no!“
Synchronous communication is the crystal meth of distributed programming
T
- dd Montgomery and Martin Thompson
in “How did we end up here” at GOT
O Chicago 2015
Challenges of asynchronicity
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Asynchronous communication
You need to monitor timeouts
Check-in
Barcode Generator
Web-UI
Me
Output Mgmt
Remember…
The failure never leaves this scope!
Workflow…
Workflow…
has to implement
Timeout, Retry
has to implement
Idempotency
Client Service Provider
Who uses a message bus?
Who has no problems
- perating 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 th thundering ering her erds
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/
Distributed T ransactions Distributed T ransactions
Distributed systems
Pat Helland
Grown-Ups Don’t Use Distributed T ransactions
“
Distributed Systems Guru Worked at Amazon, Microsoft & Salesforce
Distributed transactions using compensation *
Compensation
Eventual consistency
T emporarily inconsistent state But only temporarily!
Live hacking
https://github.com/berndruecker/flowing-retail
has to implement
Timeout, Retry, Compensation
has to offer
Compensation
has to implement
Idempotency
Client Service Provider
has to implement
Timeout, Retry, Compensation
has to offer
Compensation
has to implement
Idempotency
Client Service Provider
Don‘t forget about state
Event-driven example also available
Inventory Payment Order Shipping Checkout Monitor
https://github.com/flowing/flowing-retail/
Human T asks
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 it
e.g. Circuit breaker (Hystrix) Workflow engine for stateful retry, waiting, timeout and compensation (Camunda)
Thank you!
mail@berndruecker.io @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/