reactive systems: 21st architecture for 21st century systems
TRANSCRIPT
![Page 2: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/2.jpg)
![Page 3: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/3.jpg)
Dave Farley http://www.davefarley.net @davefarley77
http://www.continuous-delivery.co.uk
Reactive Systems
21st Century Architecture for 21st Century Problems
![Page 4: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/4.jpg)
Our World Is ChangingLarge 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
![Page 5: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/5.jpg)
Our World Is Changing
![Page 6: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/6.jpg)
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
![Page 7: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/7.jpg)
Reactive Systems Are:
Responsive:• Responds in a Timely Manner • Cornerstone of Usability • Also Quick to Detect Problems
![Page 8: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/8.jpg)
Reactive Systems Are:
Resilient:• Remains Responsive in the Face of Failure • Resilience Depends on - Replication,
Containment, Isolation and Delegation
![Page 9: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/9.jpg)
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
![Page 10: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/10.jpg)
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
![Page 11: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/11.jpg)
Properties of Reactive Systems
• Flexible
• Loosely-Coupled
• Scalable
• Easier to Develop
• More Tolerant of Failure
• Respond to Failure Gracefully
• Responsive to Users
![Page 12: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/12.jpg)
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
![Page 13: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/13.jpg)
Failure Modes in Synchronous Messaging
Component ‘B’Component ‘A’
![Page 14: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/14.jpg)
Synch Messaging Breeds Complexity
Component ‘B’Component ‘A’
Synchronous Comms Increases Coupling in Location and Time
![Page 15: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/15.jpg)
Synch Messaging Breeds Complexity
Component ‘B’Component ‘A’
?
![Page 16: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/16.jpg)
Component ‘A’
The Benefits of Asynchrony
Component ‘B’
Single Threaded!
Single Threaded!
![Page 17: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/17.jpg)
An Example
Component ‘B’Component ‘A’BookStore InventoryOrder(“Continuous Delivery”) Reserve(“Continuous Delivery”)
Order(“Continuous Delivery”) Reserve(“Continuous Delivery”)
Ordered(“Continuous Delivery”) Ordered(“Continuous Delivery”)
![Page 18: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/18.jpg)
An Example
BookStore Inventory
rese
rvin
gor
dere
d
rese
rvin
gOrder(“Continuous Delivery”) Reserve(“Continuous Delivery”)
Ordered(“Continuous Delivery”) Ordered(“Continuous Delivery”)
Order(“Better Aerobatics”) Reserve(“Better Aerobatics”)
Ordered(“Better Aerobatics”)
orde
red
Ordered(“Better Aerobatics”)
![Page 19: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/19.jpg)
5
An Example of Idempotence
Component ‘B’1
23
4567
8123
4567
8 12
Expected(3)
34
3
433412
Component ‘A’1
23
4567
8123
4567
8 123
45
5
![Page 20: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/20.jpg)
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
![Page 21: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/21.jpg)
Isolation
Component ‘A’ Component ‘B’
![Page 22: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/22.jpg)
Share Nothing
Component ‘A’ Component ‘B’
![Page 23: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/23.jpg)
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
![Page 24: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/24.jpg)
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!
![Page 25: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/25.jpg)
Queues Represent an Unstable StateQueues 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!
?
![Page 26: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/26.jpg)
Back-Pressure
Component ‘B’Component ‘A’
Slightly Faster Slightly Slower
Always Full! Back-Pressure!Component ‘n’Back-Pressure!
![Page 27: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/27.jpg)
Eventual Consistency
Component ‘A’ Component ‘B’
![Page 28: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/28.jpg)
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
![Page 29: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/29.jpg)
Linear Scalability Through Sharding
Component ‘A’ Component ‘B’
![Page 30: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/30.jpg)
Component ‘B2’
Component ‘B1’
Linear Scalability Through Sharding
Component ‘A’
![Page 31: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/31.jpg)
Modern Hardware Should Change Our Assumptions
• For Efficient Software, The Biggest Cost is Shifting Data
• RAM is Not Random Access
• Disk is Not Random Access
• SSD is Not Random Access
• RAM is Slow, Network is Slow, Disk is Slower
![Page 32: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/32.jpg)
Conway’s Law
Siloed Teams Rigid Architecture
DB
UI Specialists
MiddlewareSpecialists
DBSpecialists
![Page 33: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/33.jpg)
Conway’s Law
Cross-Functional Teams
Organised by Business Function
Distributed Service Architecture
![Page 34: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/34.jpg)
Bounded Contexts• Each Component Is Autonomous and Isolated
• It Only Communicates Through Well Defined Protocols
• Works Best When Components Are Aligned With Bounded Contexts
• Bounded Contexts Are A Concept From Domain Drive Design (DDD) - Eric Evans
• Bounded Context: • The Context Within Which A Model Of the Problem Domain Make Sense
• There Should Be ‘Translations’ Between Bounded Contexts - No “One Model To Rule Them All”
• Bounded Contexts Tend To Align With Business Functions
• Best Way To Decompose Organisations And Systems
![Page 35: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/35.jpg)
Example Reactive, MicroService architecturePublic 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 VenueExecution VenueExecution Venue
(Markets & Matching)
Execution
Management ServiceExecution
Management ServiceExecution
Management Service
(Accounts & Positions)Core Services General Services
Gateway Services
Gateway Services
Control Message Bus
![Page 36: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/36.jpg)
Where to start?
![Page 37: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/37.jpg)
Q&A
http://www.continuous-delivery.co.uk
Dave Farley http://www.davefarley.net @davefarley77
![Page 38: Reactive Systems: 21st Architecture for 21st Century Systems](https://reader031.vdocuments.site/reader031/viewer/2022020601/5796d1ff1a28abff7e8c2d73/html5/thumbnails/38.jpg)