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.

Reactive Systems by Dave Farley at #AgileIndia2019

21 views

Published on

21st century problems cannot be solved with 20th century software architectures. So why is the starting point for so many projects built on the assumption of a simplistic monolithic, three-layer architecture sat on top of a RDBMS? Hardware has progressed. It has changed many of the assumptions that such architectures were built upon. Modern systems are distributed, deal with massive throughput of data and transactions. Users expect 24/7 service.

The Reactive Manifesto describes what it takes to build systems that meet these demands. Such systems are Responsive, Resilient, Elastic and Message Driven. What does this mean in terms of software architecture and design? This presentation will introduce these ideas and describe how systems built on these principles work.


More details:
https://confengine.com/agile-india-2019/proposal/8536/reactive-systems

Conference link: https://2019.agileindia.org

  • Be the first to comment

  • Be the first to like this

Reactive Systems by Dave Farley at #AgileIndia2019

  1. 1. Dave Farley http://www.davefarley.net @davefarley77 http://www.continuous-delivery.co.uk Reactive Systems 21st Century Architecture for 21st Century Problems
  2. 2. Our World Is Changing Large Applications circa 2005: • 10’s of Servers • Seconds of Response Time • Hours of Offline Maintenance • Gigabytes of Data
 Large Applications Now: • Handheld Devices to 1000’s of multi-core processors • Millisecond Response Time • 100% Uptime • Petabytes of Data
  3. 3. Our World Is Changing
  4. 4. Mechanical Sympathy What if 1 CPU cycle took 1 second?
  5. 5. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s
  6. 6. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s
  7. 7. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s
  8. 8. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s
  9. 9. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s Main Memory Access 120 ns 6 min
  10. 10. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s Main Memory Access 120 ns 6 min Computer to Compter over 10m fibre 20.05 us 18 h
  11. 11. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s Main Memory Access 120 ns 6 min Computer to Compter over 10m fibre 20.05 us 18 h Solid-state disk I/O 100 us 4 days
  12. 12. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s Main Memory Access 120 ns 6 min Computer to Compter over 10m fibre 20.05 us 18 h Solid-state disk I/O 100 us 4 days Spinning Rust I/O 5 ms 6 months
  13. 13. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s Main Memory Access 120 ns 6 min Computer to Compter over 10m fibre 20.05 us 18 h Solid-state disk I/O 100 us 4 days Spinning Rust I/O 5 ms 6 months Internet London to Australia 180 ms 19 years
  14. 14. Mechanical Sympathy 1 CPU cycle 0.3 ns 1 s Level 1 Cache Hit 0.9 ns 3 s Level 2 Cache Hit 2.8 ns 9 s Level 3 Cache Hit 12.9 ns 43 s Main Memory Access 120 ns 6 min Computer to Compter over 10m fibre 20.05 us 18 h Solid-state disk I/O 100 us 4 days Spinning Rust I/O 5 ms 6 months Internet London to Australia 180 ms 19 years Computer Reboot 5 min 31,000 years
  15. 15. The Reactive Manifesto Responsive Elastic Resilient Message Driven “21st Century Problems are not best solved with 20th Century Software Architectures” The Evolution of modern hardware has changed many of the common assumptions of software development Source: www.reactivemanifesto.org
  16. 16. Reactive Systems Are: Responsive: • Responds in a Timely Manner • Cornerstone of Usability • Also Quick to Detect Problems
  17. 17. Reactive Systems Are: Resilient: • Remains Responsive in the Face of Failure • Resilience Depends on - Replication, Containment, Isolation and Delegation
  18. 18. Reactive Systems Are: Elastic: • Remains Responsive Under Varying Workload • Responds to Change in the Input Rate By Increasing or Decreasing Resources that Service the Input • Decentralised Architecture, No Contention Points, No Central Bottlenecks
  19. 19. Reactive Systems Are: Message Driven: • Asynchronous Message Passing is the foundation for all of these properties • Loose-Coupling, Isolation, Location Transparency • Ability to Delegate Errors
  20. 20. Properties of Reactive Systems • Flexible • Loosely-Coupled • Scalable • Easier to Develop • More Tolerant of Failure • Respond to Failure Gracefully • Responsive to Users
  21. 21. Fractal Architecture • Large Systems Are Composed of Smaller Ones • They Depend on the Reactive Properties of Their Constituents • These Benefits Operate At All Scales • Such Systems are Composable
  22. 22. Fractal Architecture • Large Systems Are Composed of Smaller Ones • They Depend on the Reactive Properties of Their Constituents • These Benefits Operate At All Scales • Such Systems are Composable
  23. 23. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  24. 24. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  25. 25. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  26. 26. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  27. 27. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  28. 28. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  29. 29. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  30. 30. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  31. 31. Failure Modes in Synchronous Messaging Component ‘B’Component ‘A’
  32. 32. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  33. 33. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  34. 34. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  35. 35. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  36. 36. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  37. 37. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  38. 38. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’ Synchronous Comms Increases Coupling in Location and Time
  39. 39. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  40. 40. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  41. 41. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  42. 42. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’
  43. 43. Synch Messaging Breeds Complexity Component ‘B’Component ‘A’ ?
  44. 44. The Benefits of Asynchrony
  45. 45. Component ‘A’ The Benefits of Asynchrony Component ‘B’
  46. 46. Component ‘A’ The Benefits of Asynchrony Component ‘B’
  47. 47. Component ‘A’ The Benefits of Asynchrony Component ‘B’
  48. 48. Component ‘A’ The Benefits of Asynchrony Component ‘B’
  49. 49. Component ‘A’ The Benefits of Asynchrony Component ‘B’
  50. 50. Component ‘A’ The Benefits of Asynchrony Component ‘B’
  51. 51. Component ‘A’ The Benefits of Asynchrony Component ‘B’ Single Threaded! Single Threaded!
  52. 52. An Example Component ‘B’Component ‘A’
  53. 53. An Example BookStore Inventory
  54. 54. An Example BookStore Inventory Order(“Continuous Delivery”)
  55. 55. An Example BookStore Inventory Order(“Continuous Delivery”) Reserve(“Continuous Delivery”)
  56. 56. An Example BookStore Inventory Order(“Continuous Delivery”) Reserve(“Continuous Delivery”)
  57. 57. An Example BookStore Inventory Order(“Continuous Delivery”) Reserve(“Continuous Delivery”)
  58. 58. An Example BookStore Inventory
  59. 59. An Example BookStore Inventory Order(“Continuous Delivery”) Reserve(“Continuous Delivery”)
  60. 60. An Example BookStore Inventory Order(“Continuous Delivery”) Reserve(“Continuous Delivery”) Ordered(“Continuous Delivery”) Ordered(“Continuous Delivery”)
  61. 61. An Example BookStore Inventory
  62. 62. An Example BookStore Inventory reserving reserving Ordered(“Continuous Delivery”) Ordered(“Continuous Delivery”)
  63. 63. An Example BookStore Inventory ordered reserving Ordered(“Continuous Delivery”) Ordered(“Continuous Delivery”)
  64. 64. Services as State Machines • Extremely useful pattern • Very simple… • Use Domain-level message semantics • Migrate state of domain model based on message input • Generate events on state change • Run business logic on a single thread
  65. 65. Services As State Machines BookStore Inventory
  66. 66. Services As State Machines BookStore Inventory Order ‘CD Book’
  67. 67. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering
  68. 68. Services As State Machines BookStore Inventory Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering
  69. 69. Services As State Machines BookStore Inventory Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering Change State of ‘CD Book’ to Reserved
  70. 70. Services As State Machines BookStore Inventory Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to Reserved
  71. 71. Services As State Machines BookStore Inventory Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to Ordered Change State of ‘CD Book’ to Reserved
  72. 72. Services As State Machines BookStore Inventory Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to OrderedOrdered ‘CD Book’ Change State of ‘CD Book’ to Reserved
  73. 73. Services As State Machines BookStore Inventory Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to OrderedOrdered ‘CD Book’ Change State of ‘CD Book’ to Reserved
  74. 74. Services As State Machines BookStore Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to OrderedOrdered ‘CD Book’ Change State of ‘CD Book’ to Reserved
  75. 75. Services As State Machines BookStore Order ‘CD Book’ Reserve ‘CD Book’ Change State of ‘CD Book’ to Ordering
  76. 76. Services As State Machines BookStore Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Reserve ‘CD Book’
  77. 77. Services As State Machines BookStore Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Reserve ‘CD Book’ List Books By State Ordering List of Books in Ordering State Som etim e Later…
  78. 78. Services As State Machines BookStore Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Reserve ‘CD Book’ List Books By State Ordering List of Books in Ordering State Do Some Admin or Something Som etim e Later…
  79. 79. Services As State Machines BookStore Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Reserve ‘CD Book’
  80. 80. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Reserve ‘CD Book’
  81. 81. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Reserve ‘CD Book’
  82. 82. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering Change State of ‘CD Book’ to Reserved Reserve ‘CD Book’
  83. 83. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to Reserved Reserve ‘CD Book’
  84. 84. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to Ordered Change State of ‘CD Book’ to Reserved Reserve ‘CD Book’
  85. 85. Services As State Machines BookStore Inventory Order ‘CD Book’ Change State of ‘CD Book’ to Ordering ‘CD Book’ Reserved Change State of ‘CD Book’ to OrderedOrdered ‘CD Book’ Change State of ‘CD Book’ to Reserved Reserve ‘CD Book’
  86. 86. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8
  87. 87. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8
  88. 88. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1
  89. 89. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2
  90. 90. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2
  91. 91. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2
  92. 92. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3
  93. 93. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 4334 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3 4
  94. 94. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 43 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3 4
  95. 95. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 343 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3 4
  96. 96. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 343 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3 45
  97. 97. 5 An Example of Idempotence Component ‘B’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3 4 3 Component ‘A’ 1 2 3 45 6 7 81 2 3 45 6 7 8 1 2 3 45 5
  98. 98. Isolation • Decoupling in Time and Space • Time - Sender and Receiver have independent lifecycle • Space - Location Transparency • Share Nothing! • Built on Inter-Component Communication over Well Defined Protocols
  99. 99. Isolation Component ‘A’ Component ‘B’
  100. 100. Isolation Component ‘A’ Component ‘B’
  101. 101. Isolation Component ‘A’ Component ‘B’
  102. 102. Isolation Component ‘A’ Component ‘B’
  103. 103. Isolation Component ‘A’ Component ‘B’
  104. 104. Isolation Component ‘A’ Component ‘B’
  105. 105. Isolation Component ‘A’ Component ‘B’
  106. 106. Share Nothing Component ‘A’ Component ‘B’
  107. 107. Share Nothing Component ‘A’ Component ‘B’
  108. 108. Back-Pressure • You Can’t Isolate Stress • The System as a Whole Needs to Respond Sensibly • Unacceptable For a Stressed Component to Fail Catastrophically or Loose Messages • Queues Represent An Unstable State - Load • Components Under Stress Need to Reflect This By Applying Back-Pressure, Slowing Upstream Inputs
  109. 109. Queues Represent an Unstable State Queues are always full or always empty. Anything else is transitional, on its way to full or empty.
  110. 110. Queues Represent an Unstable State Component ‘B’Component ‘A’ Queues are always full or always empty. Anything else is transitional, on its way to full or empty.
  111. 111. Queues Represent an Unstable State Component ‘B’Component ‘A’ Queues are always full or always empty. Anything else is transitional, on its way to full or empty. Slightly FasterSlightly Slower Always Empty!
  112. 112. Queues Represent an Unstable State Queues are always full or always empty. Anything else is transitional, on its way to full or empty.
  113. 113. Queues Represent an Unstable State Queues are always full or always empty. Anything else is transitional, on its way to full or empty. Component ‘B’Component ‘A’ Slightly Faster Slightly Slower Always Full!
  114. 114. Queues Represent an Unstable State Queues are always full or always empty. Anything else is transitional, on its way to full or empty. Component ‘B’Component ‘A’ Slightly Faster Slightly Slower Always Full!?
  115. 115. Queues Represent an Unstable State Queues are always full or always empty. Anything else is transitional, on its way to full or empty. Component ‘B’ Slightly Faster Slightly Slower Always Full!
  116. 116. Never Use Unbounded Queues! “I know let’s allow our queues to grow” Component ‘A’ Slightly Faster Component ‘B’ Slightly Slower
  117. 117. Never Use Unbounded Queues! “I know let’s allow our queues to grow” Component ‘A’ Slightly Faster Component ‘B’ Slightly Slower
  118. 118. Never Use Unbounded Queues! “I know let’s allow our queues to grow”
  119. 119. Back-Pressure Component ‘B’Component ‘A’ Slightly Faster Slightly Slower Always Full!
  120. 120. Back-Pressure ComponentComponent ‘A’ Slightly Faster Slightly Slow Always Full! Back-Pressure!
  121. 121. Back-Pressure Component ‘A’ Slightly Faster Back-Pressure!Component ‘n’Back-Pressure!
  122. 122. Location Transparency • Elastic Systems Need To React To Changes In Demand • We Are All Doing Distributed Computing • Embracing This Means There Is No Difference Between Horizontal (Cluster) and Vertical (Multicore) Scalability • Components Should Be Mobile • One Pattern For Communications • Local Communications Is An Optimisation
  123. 123. Linear Scalability Through Sharding Component ‘A’ Component ‘B’
  124. 124. Linear Scalability Through Sharding Component ‘A’ Component ‘B’
  125. 125. Component ‘B2’ Component ‘B1’ Linear Scalability Through Sharding Component ‘A’
  126. 126. Component ‘B2’ Component ‘B1’ Linear Scalability Through Sharding Component ‘A’
  127. 127. So What does this all look like? Component ‘A’ Component ‘B’ Component ‘C’ Component ‘D’ HTTP
  128. 128. So What does this all look like? Component ‘A’ Component ‘B’ Component ‘C’ Component ‘D’ HTTP
  129. 129. So What does this all look like? Component ‘A’ Component ‘B’ Component ‘C’ Component ‘D’ HTTP
  130. 130. So What does this all look like? Component ‘A’ Component ‘B’ Component ‘C’ Component ‘D’ HTTP
  131. 131. So What does this all look like? Component ‘A’ Component ‘B’ Component ‘C’ Component ‘D’ HTTP
  132. 132. So What does this all look like? Component ‘A’ Component ‘B’ Component ‘C’ Component ‘D’ HTTP
  133. 133. Example Reactive, MicroService architecture Public API Notification Service Market Management Application Customer Service Application TFX Application Public Web App Contact Service Trade Report Service Account Service Customer Service Market Management Payment Service Market Makers FIX Gateways Instrument Service Notification Service Market Data Consumers Clearing Gateways Public Message Bus Execution Venue Execution Venue Execution Venue (Markets & Matching) Execution Management Service Execution Management Service Execution Management Service (Accounts & Positions) Control Message Bus
  134. 134. Example Reactive, MicroService architecture Public API Notification Service Market Management Application Customer Service Application TFX Application Public Web App Contact Service Trade Report Service Account Service Customer Service Market Management Payment Service Market Makers FIX Gateways Instrument Service Notification Service Market Data Consumers Clearing Gateways Public Message Bus Execution Venue Execution Venue Execution Venue (Markets & Matching) Execution Management Service Execution Management Service Execution Management Service (Accounts & Positions)Core Services Control Message Bus
  135. 135. Example Reactive, MicroService architecture Public API Notification Service Market Management Application Customer Service Application TFX Application Public Web App Contact Service Trade Report Service Account Service Customer Service Market Management Payment Service Market Makers FIX Gateways Instrument Service Notification Service Market Data Consumers Clearing Gateways Public Message Bus Execution Venue Execution Venue Execution Venue (Markets & Matching) Execution Management Service Execution Management Service Execution Management Service (Accounts & Positions)Core Services General Services Control Message Bus
  136. 136. Example Reactive, MicroService architecture Public API Notification Service Market Management Application Customer Service Application TFX Application Public Web App Contact Service Trade Report Service Account Service Customer Service Market Management Payment Service Market Makers FIX Gateways Instrument Service Notification Service Market Data Consumers Clearing Gateways Public Message Bus Execution Venue Execution Venue Execution Venue (Markets & Matching) Execution Management Service Execution Management Service Execution Management Service (Accounts & Positions)Core Services General Services Gateway Services Gateway Services Control Message Bus
  137. 137. Example Reactive, MicroService architecture Public API Notification Service Market Management Application Customer Service Application TFX Application Public Web App Contact Service Trade Report Service Account Service Customer Service Market Management Payment Service Market Makers FIX Gateways Instrument Service Notification Service Market Data Consumers Clearing Gateways Public Message Bus Execution Venue Execution Venue Execution Venue (Markets & Matching) Execution Management Service Execution Management Service Execution Management Service (Accounts & Positions) Control Message Bus
  138. 138. Q&A http://www.continuous-delivery.co.uk Dave Farley http://www.davefarley.net @davefarley77

×