Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Rise of Reactive Microservices

E6c61f085d7aceaf97b7bd00e9195514?s=47 SQUER Solutions
June 15, 2022
48

The Rise of Reactive Microservices

WeAreDevelopers — Berlin

E6c61f085d7aceaf97b7bd00e9195514?s=128

SQUER Solutions

June 15, 2022
Tweet

Transcript

  1. WeAreDevelopers 2022 — Berlin @duffleit

  2. David Leitner @duffleit Coding Architect david@squer.at @duffleit

  3. @duffleit Somewhen in 2011.

  4. @duffleit User <μService> Account <μService> Legder <μService> WebBanking New Payment

    💸 Perform Payment € 20, 00 👧 Lisa to David from transferMoney triggerPayment createTransactions
  5. @duffleit User <μService> Account <μService> Legder <μService> WebBanking Your payment

    was successfully executed. transferMoney triggerPayment createTransactions ✅
  6. @duffleit User <μService> Account <μService> Legder <μService> WebBanking New Payment

    💸 Perform Payment € 20, 00 👧 Lisa to David from transferMoney triggerPayment createTransactions <μService> Legder Legder <μService>
  7. @duffleit User <μService> Account <μService> Legder <μService> WebBanking Your payment

    was successfully executed. transferMoney triggerPayment createTransactions ✅ Retries Timeouts Circuit Breakers Synchronise
  8. First Generation of MicroServices Synchronously Integrated @duffleit

  9. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment New Payment

    💸 € 20, 00 👧 Lisa to David from Perform Payment <μService> Legder
  10. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment New Payment

    💸 € 20, 00 👧 Lisa to David from Perform Payment <μService> Legder
  11. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Queue <μService> Legder
  12. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Queue <μService> Legder
  13. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Queue <μService> Legder
  14. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Queue <μService> Legder
  15. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Queue <μService> Legder
  16. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions Queue

    <μService> Legder Your payment was accepted. ✅
  17. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions Queue

    <μService> Legder Your payment was accepted. ✅ Legder <μService>
  18. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions Queue

    <μService> Legder Your payment was accepted. ✅ Legder <μService>
  19. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions Queue

    <μService> Legder Your payment was accepted. ✅ Legder <μService> Queue
  20. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions Queue

    <μService> Legder Your payment was accepted. ✅ Legder <μService> Queue Queue
  21. Second Generation of MicroServices Message-Driven and Asynchronously Integrated @duffleit

  22. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Legder <μService> Queue Queue Queue
  23. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Legder <μService> Queue Queue Queue As a Customer, I want my transaction to be booked by the ledger.
  24. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Legder <μService> Queue Queue Queue As a Customer, I want the account service to update my balance.
  25. @duffleit User <μService> Account <μService> WebBanking transferMoney triggerPayment createTransactions New

    Payment 💸 € 20, 00 👧 Lisa to David from Perform Payment Legder <μService> Queue Queue Queue As a Customer, I want to transfer money to someone else.
  26. The Entity Service Antipattern. @duffleit

  27. Let's create Services along Customer Journeys. @duffleit

  28. @duffleit “ On the Criteria To Be Used in Decomposing

    Systems into Modules — Parnas, 1972
  29. Let's create Services along Customer Journeys. @duffleit

  30. @duffleit User <μService> Account <μService> WebBanking New Payment 💸 €

    20, 00 👧 Lisa to David from Perform Payment Legder <μService> Payments <μService> Domain Services Journey Services As a Customer, I want to transfer money to someone else.
  31. @duffleit User <μService> Account <μService> WebBanking New Payment 💸 €

    20, 00 👧 Lisa to David from Perform Payment Legder <μService> Web-BFF <μService> Domain Services Backend For Frontends As a Customer, I want to transfer money to someone else. Mobile-BFF <μService> Mobile Banking € 20, 00 Pay Payment Flow Payment Flow
  32. @duffleit No Domain Logic in Backend For Frontends. It's about

    Ui-Specific Aggregation, to get rid of over-fetching and over-requesting.
  33. @duffleit User <μService> Account <μService> WebBanking New Payment 💸 €

    20, 00 👧 Lisa to David from Perform Payment Legder <μService> Payments <μService> Domain Services Journey Services
  34. @duffleit User <μService> Account <μService> WebBanking New Payment 💸 €

    20, 00 👧 Lisa to David from Perform Payment Legder <μService> Payments <μService> Domain Services Journey Services Balance <μService>
  35. @duffleit ⚡ Customer Journey & Entity Data Mismatch Problem

  36. @duffleit Users Accounts Transactions Entities Customer Journeys Payments Onboarding Fraud

    Detection ⚡
  37. @duffleit User Account WebBanking New Payment 💸 € 20, 00

    👧 Lisa to David from Perform Payment Transactions Payments Domain Services Journey Services Onboarding Fraud Detection User Account Account Transactions
  38. @duffleit User Account WebBanking New Payment 💸 € 20, 00

    👧 Lisa to David from Perform Payment Transactions Payments Domain Services Journey Services Onboarding Fraud Detection User Account Account Transactions ⚡ ⚡ ⚡
  39. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Service Autnomy
  40. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Data Duplication ⚡
  41. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Data Syncronisation 🤯 ⚡
  42. @duffleit clarify who owns which Data. Always

  43. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions
  44. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Synchronous Calls 😔
  45. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Synchronous Calls 😔
  46. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Cache Account Transactions Synchronous Calls 😔
  47. @duffleit There must be a better solution 🤔

  48. @duffleit There must be a better solution 🤔 Payments User

    Onboarding User pull
  49. @duffleit There must be a better solution 🤔 Payments User

    Onboarding User push
  50. @duffleit Payments Onboarding User Aggregate User Readmodel UserChangedEvent UserChange Command

    That's CQRS in a nutshell 🥜 update
  51. @duffleit Payments Onboarding User Aggregate User Readmodel UserChangedEvent UserChange Command

    Stream
  52. @duffleit Payments Onboarding User Aggregate User Readmodel UserChange Command Stream

    UserChangedEvent transform apply
  53. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream
  54. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream
  55. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream
  56. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream
  57. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream Projections
  58. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream Projections
  59. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream Projections
  60. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream Projections
  61. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream
  62. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream Projections
  63. @duffleit But didn't we just introduce Eventual Consistency?

  64. @duffleit The different faces of Eventual Consistency

  65. @duffleit Eventual Consistency Eventual Divergence Dashboard User (age: 22) UserChanged

    (age: 21) UserChanged (age: 22) Profile User (age: 21) ⚡ timestamp timestamp
  66. @duffleit Eventual Consistency Eventual Divergence Eventual Variance Ledger Stream Transaction

    (+10€) 🔥
  67. @duffleit Eventual Consistency Eventual Divergence Eventual Variance Ledger Dashboard Stream

    🔥 Transaction (+10€) Transaction (+10€) Balance: 20€
  68. @duffleit Eventual Consistency Eventual Divergence Eventual Variance Eventual Latency Service

    B Stream UserChanged (age: 21) UserChanged (age: 22) Profile User (age: 21) Dashboard User (age: 21) User (age: 22)
  69. Single User Context @duffleit Eventual Consistency Eventual Divergence Eventual Variance

    Eventual Latency Service B Stream UserChanged (age: 21) UserChanged (age: 22) Profile User (age: 21) Dashboard User (age: 21) User (age: 22) 🕰
  70. @duffleit Eventual Consistency Eventual Divergence Eventual Variance Eventual Latency same

    events, different results. same events, different quantity. same events, different realisation. Ordering Guarantees Optimistic UIs At-Least-Once Delivery Deduplication Mechanisms
  71. @duffleit tl/dr: Eventual Consistency is often used as a knock-out

    argument @duffleit
  72. @duffleit tl/dr: Eventual Consistency is often used as a knock-out

    argument but isn't, in most cases. @duffleit
  73. @duffleit WebBanking New Payment 💸 € 20, 00 👧 Lisa

    to David from Perform Payment Payments Journey Services Onboarding Fraud Detection User Account Account Transactions User Account Transactions Stream Projections
  74. @duffleit Mobile Banking Usage 93% — Show balance & last

    transactions 3% — Initiate new payment 4% — Any other functionality
  75. @duffleit Payments Journey Services Onboarding Overview User Account Account Transactions

    User Account Transactions Stream
  76. @duffleit Payments Journey Services Onboarding Overview User Account Account Transactions

    User Account Transactions Stream
  77. @duffleit Payments Journey Services Onboarding Overview User Account Account Transactions

    User Account Transactions Stream
  78. @duffleit Payments Journey Services Onboarding Overview User Account Account Transactions

    User Account Transactions Stream
  79. @duffleit Payments Journey Services Onboarding Overview User Account Account Transactions

    User Account Transactions Stream
  80. @duffleit Payments Journey Services Onboarding Overview User Account Account Transactions

    User Account Transactions Stream 93% of what our users need can still be performed. WebBanking Current Balance: 200€ 👧 You sent Lisa 100€ Christoph sent you 300€
  81. @duffleit WebBanking Current Balance: 200€ 👧 You sent Lisa 100€

    Christoph sent you 300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream Overview Transactions We can easily scale horizontally.
  82. @duffleit WebBanking Current Balance: 200€ 👧 You sent Lisa 100€

    Christoph sent you 300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream Overview Transactions We can easily scale horizontally.
  83. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  84. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  85. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  86. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  87. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  88. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  89. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment
  90. @duffleit WebBanking of David Current Balance: 300€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment 👧 Lisa sent you 20€
  91. @duffleit WebBanking of David Current Balance: 320€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment 👧 Lisa sent you 20€
  92. @duffleit WebBanking of David Current Balance: 320€ Christoph sent you

    300€ Payments Journey Services Onboarding Overview User Account Transactions User Account Transactions Stream WebBanking of Lisa 👧 New Payment 💸 € 20, 00 David to 👧 Lisa from Perform Payment 👧 Lisa sent you 20€ GraphQL subscriptions mutations Out-of-the-box real-time capabilities.
  93. @duffleit WebBanking of David Current Balance: 320€ Christoph sent you

    300€ Payments Journey Services Legacy System Accounts Stream 👧 Lisa sent you 20€ User 😮 💨😮 💨 😮 💨 Change Data Capture (CDC) User User
  94. Third Generation of MicroServices Built on Reactive Data-Streams @duffleit High

    Resilience 🔥 Horizontal Scaling ↔ Real Time Integration ⏱ Good Integration with Legacy Systems 🏚
  95. Dimensions of Scaling @duffleit Vertical Horizontal Service

  96. Dimensions of Scaling @duffleit Vertical Horizontal Service

  97. Dimensions of Scaling Vertical Horizontal Service Service' Service'' Stream

  98. Dimensions of Scaling Vertical Horizontal Service Service' Service'' Stream

  99. Dimensions of Scaling Vertical Horizontal Service Service' Service'' Sharding

  100. Dimensions of Scaling Vertical Horizontal Service Service' Service'' Sharding Users

    A-H Users I-P Users Q-Z
  101. Dimensions of Scaling Vertical Horizontal Service Service' Service'' User from

    User from Users from Service Service Service Sharding
  102. @duffleit UserTriggeredPayment

  103. @duffleit Stream UserTriggeredPayment Partition 0 Partition 1 Partition 2 UserTriggeredPayment

  104. @duffleit Stream UserTriggeredPayment Partition 0 Partition 1 Partition 2 UserTriggeredPayment

  105. @duffleit Stream UserTriggeredPayment Partition 0 Partition 1 Partition 2 UserTriggeredPayment

    Payments Payments Payments
  106. @duffleit Stream UserTriggeredPayment Partition 0 Partition 1 Partition 2 UserTriggeredPayment

    Payments Payments Payments ValidPaymentReceived
  107. @duffleit Stream UserTriggeredPayment Partition 0 Partition 1 Partition 2 UserTriggeredPayment

    Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2
  108. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection PaymentCheckedAgainstFraud
  109. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Stream PaymentChecked Partition 0 Partition 1 Partition 2
  110. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Stream PaymentChecked Partition 0 Partition 1 Partition 2 Ledger Ledger Ledger TransactionBooked
  111. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Stream PaymentChecked Partition 0 Partition 1 Partition 2 Ledger Ledger Ledger Partition 0 Partition 1 Partition 2 Stream TransactionBooked
  112. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Partition 0 Partition 1 Partition 2 Ledger Ledger Ledger Partition 0 Partition 1 Partition 2 Projecting Transactions Streams Flink Stream PaymentChecked Stream TransactionBooked Independent Shards
  113. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Stream PaymentChecked Partition 0 Partition 1 Partition 2 Ledger Ledger Ledger Partition 0 Partition 1 Partition 2 Stream TransactionBooked Shard 0 Shard 1 Shard 2 DataSink Streams Flink Projecting Transactions WebBanking WebBanking WebBanking
  114. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Stream PaymentChecked Partition 0 Partition 1 Partition 2 Ledger Ledger Ledger Partition 0 Partition 1 Partition 2 Stream TransactionBooked Shard 0 Shard 1 Shard 2 DataSink Streams Flink Projecting Transactions WebBanking WebBanking WebBanking
  115. Fraud Detection Fraud Detection @duffleit Stream UserTriggeredPayment Partition 0 Partition

    1 Partition 2 UserTriggeredPayment Payments Payments Payments Stream ValidPaymentReceived Partition 0 Partition 1 Partition 2 Fraud Detection Stream PaymentChecked Partition 0 Partition 1 Partition 2 Ledger Ledger Ledger Partition 0 Partition 1 Partition 2 Stream TransactionBooked Shard 0 Shard 1 Shard 2 DataSink 🚀 We can scale nearly unlimited. Projecting Transactions WebBanking WebBanking WebBanking
  116. Forth Generation of MicroServices Shared and fully Stream Based @duffleit

    Massive Throughput 🚀 Extremely Scalable ↔
  117. So many choices, Lets sum up. @duffleit

  118. Monolith @duffleit

  119. Monolith @duffleit

  120. Syncronously 😩 Pain @duffleit

  121. Modulith @duffleit

  122. Asyncronously 📦 Shared Data @duffleit

  123. Reactive ⚡ From Pull to Push @duffleit

  124. Streaming Massiv Throughput 🚀 @duffleit

  125. Monolith Reactive Push-Based Async Pull-Based Streamed Availability 🟢 , Resilience

    🦺 , Scalability ↔ , Throughput 🚀 Complexity 💰 @duffleit The Rise of Reactive Microservices. And the future of fully Stream Based Architectures.
  126. David Leitner @duffleit Coding Architect david@squer.at @duffleit

  127. squer.link / slicing-microservices