3 Common Pitfalls in Microservice Integration (Bonus : And how to avoid them ) 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 is Challenges of Distributed complex asynchronicity Transactions
7 Some Microservices…. Some Service Some Some Service Service Some Service But keep it local! Some Service Failure will Be resilient. happen. 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 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 this scope! Stateful Me Retry Check-in Barcode Output Generator Mgmt
Handling State State machine Persist thing or workflow (Entity, Document, Actor, engine …) DIY = effort, Complex, proprietary, Typical Typical accidental heavyweight, slow, concerns concerns complexity don‘t scale, developer adverse Scheduling, Versioning, operating, visibility, scalability, …
Current Players in the State Machine Market • AWS Step Function • UBER Cadence • Netflix Conductor • Camunda • Zeebe • jBPM • Activiti
Performance: Zeebe vs. Kafka Apache Kafka Vs.
Current Players in the State Machine Market • AWS Step Function • UBER Cadence • Netflix Conductor • Camunda (Raise of hand?) • Zeebe • 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. problem anyway! Do not leave this page. And for god sake – do not reload!
Better … We are currently processing your request. Don‘t worry, it will happen We are processing your payment. safely – It is a business Do not leave this page. even if you loose connection. problem 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 Web-UI You need to monitor timeouts Me Check-in Barcode Output Generator Mgmt
Remember … Web-UI The failure never Me Check-in leaves this scope! Barcode Output Generator Mgmt
Workflow…
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 https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Other Architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
Other Architecture Options 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
Distributed transactions using compensation * 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 has to implement Compensation Idempotency
Client Service Don‘t forget Provider about state has to implement has to offer Timeout, Retry, Compensation has to implement Compensation 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
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 development, Straight-Through E-Commerce: Order operations and visibility Processing Execution of automated workflows Microservice Orchestration Finance: Stock Trading and decisions. Human Workflow Insurance: Claim Management Settlement Business Rule Automation Telco: OSS/BSS ……..
# 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
Contact Us • Andreas Stange | International Sales • +49-172-862-2730 | Berlin • Mauricio Bitencourt | Customer Delivery & Success • +55 51 984.087.798 | Sao Paulo
? Q&A
Camunda Ecosystem Model > Execute > Improve
Recommend
More recommend