3 Common Pitfalls in Microservice Integration (Bonus : And how to avoid them J ) credit to Bernd Ruecker Patricio Zambrano Technical Consultant, Camunda Inc.
2 Microservices Agenda Introduction • 3 Common Challenges and How to Avoid Them • Conclusion •
Raise your hand • REST • Microservices • Java
Distributed systems
Distributed systems Communication Challenges of Distributed is complex asynchronicity Transactions
7 Some Microservices…. Some Service Some Some Service Service Some Service But keep it Some Service Failure will local! Be happen. resilient. Some Accept it! Some Service Service
Let‘s start with a simple example Credit Payment Card REST What happens if the Credit Card Service is Super Slow? Payment Requestor Application
Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV2.java
Circuit Breaker Photo by CITYEDV, available under Creative Commons CC0 1.0 license.
Failing Fast is important…. ..but not enough
Photo by https://www.archdaily.com/560641/liverpool-insurgentes-department-store-rojkind-arquitectos
Current situation Web-UI You Check-in
Current situation Web-UI You Check-in Barcode Output Generator Mgmt
Current situation Circuit breaker Web-UI You Check-in Barcode Output Generator Mgmt
Another screenshot
Current situation – the bad part Web-UI Me Check-in Barcode Output Generator Mgmt
Current situation – the bad part Web-UI Me Check-in Barcode Output Generator Mgmt
Current situation – the bad part Web-UI Me Check-in Barcode Output Generator Stateful Mgmt Retry
Another Example Just made this up 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 on time.
Possible Solution – Much better? The failure Web-UI never leaves Stateful this scope! Retry Me Check-in Barcode Output Generator Mgmt
Handling State State Persist thing machine or (Entity, Document, workflow Actor, …) engine DIY = effort, Complex, Typical Typical accidental proprietary, concerns concerns complexity heavyweight, slow, don‘t scale, Scheduling, Versioning, developer adverse operating, visibility, scalability, …
Current Players in the State Machine Market • AWS Step Function • UBER Cadence • Netflix Conductor • Camunda J • Zeebe J • jBPM • Activiti
Performance: Zeebe vs. Kafka Apache Kafka Vs.
Current Players in the State Machine Market • AWS Step Function • UBER Cadence • Netflix Conductor • Camunda J (Raise of hand?) • Zeebe J • jBPM • Activiti
In the previous demo…. Credit Payment Card REST What if I want my Payment to be Asynchronous and Retry itself when my Credit Card Service Slow? Payment Requestor Application
Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV3.java
Demo Credit Payment Card REST What if I want a Synchronous response when everything is fast? Payment Requestor Application
Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV3.java
Now you have a state machine! Credit Payment Card REST
Most important factors to consider in distributed systems (so far.. ) Client Service Provider has to implement has to implement Retry Idempotency
Bad Example.. It is a business We are processing your payment. Do not leave this page. problem anyway! And for god sake – do not reload!
Better … We are currently processing your request. Don‘t worry, it will It is a business We are processing your payment. happen safely – Do not leave this page. problem even if you loose connection. anyway! And for god sake – do not reload! Feel free to reload this page any time!
It is impossible to differentiate certain failure Client Service Provider scenarios(and Code Exceptions). Independant of communication style!
Distributed systems introduce complexity you have to tackle! Credit Payment Card REST
Distributed systems introduce complexity you have to tackle! Credit Payment Card REST Do it reliably
Workflows live within service boundaries Web-UI Me Check-in Barcode Output Generator Mgmt
Different Architecture Options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Different architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Different architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Different architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
First Sync then Async Check-in generateBoardingPass HTTP 200 OK HTTP 202 ACCEPTED A synchronous response is possible in the happy case, otherwise it is switched to asynchronous processing.
The customer wants a synchronous response… Web-UI Me Check-in !Eh – no! Barcode Output Generator Mgmt
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
Challenges of asynchronicity
Asynchronous communication You need to Web-UI monitor timeouts Me Check-in Barcode Output Generator Mgmt
Remember… Web-UI The Me failure Check-in never leaves this Barcode Output scope! Generator Mgmt
Workflow… Easy to handle time
Workflow…
Client Service Provider has to implement has to implement Timeout, Retry Idempotency
Who uses a message bus?
Who has no problems operating a message bus? Dead messages | No context | Inaccesible payload | Hard to redeliver | Home-grown message hospitals | …
Other Architecture options A parte de imagem com identificação de relação rId5 não foi encontrada no arquivo. https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Other Architecture options A parte de imagem com identificação de relação rId4 não foi encontrada no arquivo. https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Other Architecture Options A parte de imagem com identificação de relação rId4 não foi encontrada no arquivo. https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Distributed Distributed Transactions Transactions
ACID Transactions • Scalability • Distributed Troubleshooting TM • Still Required!! • systems 2007
Distributed transactions using compensation * *aka Saga pattern Compensation
Eventual consistency Temporarily inconsistent state But only temporarily!
Demo Time Node.js App Payment Requestor Application
Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV6.java
Client Service Provider has to implement has to offer Timeout, Retry, Compensation Compensation has to implement Idempotency
Client Service Don‘t Provider forget about has to implement has to offer state Timeout, Retry, Compensation Compensation has to implement Idempotency
Before mapping processes explicitly with BPMN and DMN, the truth was buried in the code and nobody knew what was going on. Jimmy Floyd, 24 Hour Fitnesse
https://github.com/flowing/flowing- retail/tree/master/zeebe Event-driven example also available Payment Checkout Order Inventory Shipping Monitor Human Tasks H2 H2 Kafka https://github.com/flowing/flowing-retail/
Workflows live inside service boundaries Kafka or Zeebe
Reality check Sales-Order & Order-Fulfillment via Camunda for every order worldwide (Q2 2017: 22,2 Mio )
72 Some of the Workflow Engine Use Cases and… what we talked about Camunda Value Technical Use Cases Business Process Examples Improving Straight-Through E-Commerce: Order development, Processing Execution operations and visibility Microservice Finance: Stock Trading of automated Orchestration Insurance: Claim workflows and Human Workflow Settlement decisions. Management Telco: OSS/BSS Business Rule Automation ……..
# 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)
https://www.infoworld.com/article/3254777/application-development/ 3-common-pitfalls-of-microservices-integrationand-how-to-avoid-them.html
Where to learn more #6
Recommend
More recommend