Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

3 common pitfalls in microservice integration

474 views

Published on

Slides from my talk at various locations (QCon, OReilly, JBCN, ...)

Published in: Technology
  • Be the first to comment

3 common pitfalls in microservice integration

  1. 1. 3 Common Pitfalls in Microservice Integration and How to Avoid Them @berndruecker
  2. 2. Berlin, Germany bernd.ruecker@camunda.com @berndruecker Bernd Ruecker Co-founder and Developer Advocate of Camunda
  3. 3. REST, SOAP, Cloud, Saas, Microservices, SCS, FaaS, Serverless, …
  4. 4. Distributed systems
  5. 5. https://www.infoworld.com/article/3254777/application-development/ 3-common-pitfalls-of-microservices-integrationand-how-to-avoid-them.html
  6. 6. Distributed systems Challenges of asynchronicity Distributed Transactions Communication is complex
  7. 7. 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.
  8. 8. Let‘s start with a simple example Credit Card Payment REST
  9. 9. Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV2.java
  10. 10. Circuit Breaker Photo by CITYEDV, available under Creative Commons CC0 1.0 license.
  11. 11. Fail fast is important
  12. 12. Fail fast is important but not enough!
  13. 13. Photo by Tookapic, available under Creative Commons CC0 1.0 license.
  14. 14. „There was an error while sending your boarding pass“
  15. 15. Check-in Web-UI Me Current situation
  16. 16. Check-in Barcode Generator Web-UI Me Output Mgmt Current situation
  17. 17. Check-in Barcode Generator Web-UI Me Output Mgmt Current situation
  18. 18. Check-in Barcode Generator Web-UI Me Output Mgmt Current situation Circuit breaker
  19. 19. Check-in Barcode Generator Web-UI Me Output Mgmt Current situation – the bad part
  20. 20. Check-in Barcode Generator Web-UI Me Output Mgmt Current situation – the bad part
  21. 21. Check-in Barcode Generator Web-UI Me Output Mgmt Current situation – the bad part Stateful Retry
  22. 22. 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.
  23. 23. Check-in Barcode Generator Web-UI Me Output Mgmt Possible situation – much better!
  24. 24. Check-in Barcode Generator Web-UI Me Output Mgmt Possible situation – much better! Stateful Retry
  25. 25. Check-in Barcode Generator Web-UI Me Output Mgmt Stateful Retry Possible situation – much better! The failure never leaves this scope!
  26. 26. Persist thing (Entity, Document, Actor, …) State machine or workflow engine Typical concerns DIY = effort, accidental complexity Complex, proprietary, heavyweight, slow, don‘t scale, developer adverse Scheduling, Versioning, operating, visibility, scalability, … Handling State
  27. 27. Workflow engines, state machines It is relevant in modern architectures
  28. 28. CADENCE Silicon valley has recognized Workflow engines, state machines
  29. 29. CADENCE Workflow engines, state machines
  30. 30. CADENCE also at scale Workflow engines, state machines
  31. 31. CADENCE for todays demo Workflow engines, state machines
  32. 32. Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV3.java
  33. 33. Payment Now you have a state machine! Credit Card REST
  34. 34. has to implement Retry has to implement Idempotency Client Service Provider
  35. 35. We are processing your payment. Do not leave this page. And for god sake – do not reload! It is a business problem anyway!
  36. 36. 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!
  37. 37. Distributed systems introduce complexity you have to tackle! Credit Card Payment REST
  38. 38. Distributed systems
  39. 39. It is impossible to differentiate certain failure scenarios. Independant of communication style! Service Provider Client
  40. 40. Distributed systems introduce complexity you have to tackle! Credit Card Payment REST
  41. 41. Distributed systems introduce complexity you have to tackle! Credit Card Payment REST
  42. 42. BPMN Business Process Model and Notation ISO Standard
  43. 43. BPMN Executable and mature Easy to understand* Widespread *(for Biz, Dev, and Ops)
  44. 44. Proper Operations Visibility + Context
  45. 45. Compare to e.g. Step Functions
  46. 46. Workflows live within service boundaries Credit Card Payment REST
  47. 47. Check-in Barcode Generato r Web-UI Me Output Mgmt Workflows live within service boundaries
  48. 48. Check-in Barcode Generato r Web-UI Me Output Mgmt Workflows live within service boundaries
  49. 49. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  50. 50. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  51. 51. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  52. 52. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  53. 53. generateBoardingPass HTTP 200 OK HTTP 202 ACCEPTED Check-in A synchronous response is possible in the happy case, otherwise it is switched to asynchronous processing.
  54. 54. „The customer wants a synchronous response“ Check-in Barcode Generator Web-UI Me Output Mgmt „Eh – no!“
  55. 55. 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
  56. 56. Challenges of asynchronicity
  57. 57. Check-in Barcode Generator Web-UI Me Output Mgmt Asynchronous communication You need to monitor timeouts
  58. 58. Check-in Barcode Generator Web-UI Me Output Mgmt Remember… The failure never leaves this scope!
  59. 59. Workflow…
  60. 60. Workflow…
  61. 61. has to implement Timeout, Retry has to implement Idempotency Client Service Provider
  62. 62. Who uses a message bus?
  63. 63. Who has no problems operating a message bus? Dead messages | No context | Inaccesible payload | Hard to redeliver | Home-grown message hospitals | …
  64. 64. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  65. 65. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  66. 66. Manigfold architecture options https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
  67. 67. Distributed Transactions Distributed Transactions
  68. 68. Distributed systems
  69. 69. Distributed transactions using compensation * Compensation
  70. 70. Eventual consistency Temporarily inconsistent state But only temporarily!
  71. 71. Live hacking https://github.com/flowing/flowing-retail/blob/master/payment- rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV6.java
  72. 72. has to implement Timeout, Retry, Compensation has to offer Compensation has to implement Idempotency Client Service Provider
  73. 73. has to implement Timeout, Retry, Compensation has to offer Compensation has to implement Idempotency Client Service ProviderDon‘t forget about state
  74. 74. Before mapping processes explicitly with BPMN, the truth was buried in the code and nobody knew what was going on. Jimmy Floyd, 24 Hour Fitnesse „
  75. 75. Event-driven example also available InventoryPaymentOrder ShippingCheckout Monitor https://github.com/flowing/flowing-retail/ Human Tasks H2 H2
  76. 76. Workflows live inside service boundaries
  77. 77. Sales-Order & Order-Fulfillment via Camunda for every order worldwide (Q2 2017: 22,2 Mio)
  78. 78. # 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)
  79. 79. Thank you!
  80. 80. bernd.ruecker@camunda.com @berndruecker https://bernd-ruecker.com https://blog.bernd-ruecker.com https://github.com/flowing 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/

×