![Page 1: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/1.jpg)
Reactive Architecture PatternsIndependentConsultantHands-onSo*wareArchitectPublishedAuthor/ConferenceSpeaker
MarkRichards
h<p://www.wmrichards.comh<ps://www.linkedin.com/in/markrichards3@markrichardssa
![Page 2: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/2.jpg)
reactive architecture agenda
reactive architecture
overview
thread delegate pattern
consumer supervisor
pattern
workflow event
pattern
producer control flow
pattern
![Page 3: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/3.jpg)
https://github.com/wmr513/reactive
source code
![Page 4: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/4.jpg)
reactive architecturereactive manifesto
responsive
resilient
message driven
elastic
![Page 5: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/5.jpg)
reactive manifesto
the system responds in a consistent, rapid, and timely manner whenever possible
how the system reacts to users
responsive
resilient
message driven
elastic
reactive architecture
![Page 6: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/6.jpg)
reactive manifesto
the system stays responsive after a failure through replication, containment, isolation,
and delegationhow the system reacts to failures
responsive
resilient
message driven
elastic
reactive architecture
![Page 7: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/7.jpg)
reactive manifesto
the system stays responsive under varying workload
how the system reacts to load
responsive
resilient
message driven
elastic
reactive architecture
![Page 8: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/8.jpg)
reactive manifesto
the system relies on asynchronous messaging to ensure loose coupling, isolation, location
transparency, and error delegationhow the system reacts to events
responsive
resilient
message driven
elastic
reactive architecture
![Page 9: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/9.jpg)
reactive patterns for self-healing systems
event producer
event dispatcher
thread delegate
supervisorevent
dispatcherthread
delegate
event dispatcher
thread delegate
flow monitor
workflow processor
thread delegate pattern
consumer supervisor pattern
workflow event pattern
producer control flow pattern
![Page 10: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/10.jpg)
Thread Delegate Pattern
![Page 11: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/11.jpg)
thread delegate pattern
responsive
resilient
message driven
elastic
how can you ensure timely and consistent response time as your system grows?
![Page 12: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/12.jpg)
event dispatcher
event producer
thread delegate patternhow can you ensure timely and consistent
response time as your system grows?
thread delegate
![Page 13: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/13.jpg)
let’s see the issue…
thread delegate pattern
![Page 14: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/14.jpg)
event thread
event thread
thread delegate pattern
event producer
event delegate
preserving message order
12
![Page 15: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/15.jpg)
thread delegate patternpreserving message order
premise: not every message must be ordered, but rather messages within a context must be ordered
1. PLACE AAPL A-136 2,000,000.002. CANCEL AAPL A-136 2,000,000.003. REBOOK AAPL A-136 1,800,000.00
1. PLACE AAPL A-136 2,000,000.00
4. CANCEL AAPL A-136 2,000,000.005. REBOOK AAPL A-136 1,800,000.00
2. PLACE GOOG V-976 650,000.003. CANCEL GOOG V-976 650,000.00
6. REBOOK GOOG V-976 600,000.00
1, 2, 3
1, 4, 5
2, 3, 6
![Page 16: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/16.jpg)
event thread
event thread
thread delegate pattern
event producer
event delegate
preserving message order
GOOG
AAPL
![Page 17: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/17.jpg)
thread delegate pattern
event producer
preserving message order
symbol striping
event thread
event thread
event delegate
GOOG
AAPL
A-M
event thread
event thread
event delegate
XLK
XPHN-Z
![Page 18: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/18.jpg)
event dispatcher
event producer
thread delegate pattern
thread delegate
managed queued thread pool
event dispatcher models
single-use thread allocation
![Page 19: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/19.jpg)
event dispatcher
thread delegate pattern
thread delegate
single-use thread allocation
![Page 20: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/20.jpg)
event dispatcher
thread delegate patternsingle-use thread allocation
thread delegate
thread delegate
![Page 21: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/21.jpg)
event dispatcher
thread delegate patternsingle-use thread allocation
thread delegate
thread delegate
does not preserve message orderrisk of running out of threads
risk of backing up primary delegate queue
![Page 22: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/22.jpg)
event dispatcher
thread delegate patternsingle-use thread allocation
thread delegate
thread delegate
![Page 23: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/23.jpg)
thread delegate
1
thread delegate
2
thread delegate
3
event dispatcher
thread delegate patternmanaged queued thread pool
123
![Page 24: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/24.jpg)
thread delegate
1
thread delegate
2
thread delegate
3
event dispatcher
thread delegate patternmanaged queued thread pool
123
![Page 25: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/25.jpg)
thread delegate
1
thread delegate
2
thread delegate
3
event dispatcher
thread delegate patternmanaged queued thread pool
123
![Page 26: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/26.jpg)
let’s see the result…
thread delegate pattern
![Page 27: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/27.jpg)
Consumer Supervisor Pattern
![Page 28: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/28.jpg)
consumer supervisor patternhow can you react to varying changes in load
to event consumers to ensure consistent response time?
resilient
message driven
elastic
responsive
![Page 29: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/29.jpg)
consumer supervisor patternhow can you react to varying changes in load
to event consumers to ensure consistent response time?
event consumer
event channel
supervisor event consumerevent consumer
event consumer
![Page 30: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/30.jpg)
let’s see the issue….
consumer supervisor pattern
![Page 31: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/31.jpg)
consumer supervisor pattern
event consumer
event channel
supervisor event consumerevent consumerevent consumer
determine consumers needed (e.g., depth/2)
add or remove consumers as neededapply max threshold (e.g., 1000 msgs)
continually monitor queue depth (e.g., 1000ms)
![Page 32: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/32.jpg)
let’s see the result…
consumer supervisor pattern
![Page 33: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/33.jpg)
consumer supervisor pattern
event consumer
event channel
supervisor event consumerevent consumerevent consumer
super supervisor
event consumersupervisor event consumerevent consumerevent consumer
![Page 34: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/34.jpg)
thread delegate patternthread delegate vs. consumer supervisor
scalability elasticityconsistent consumers variable consumersdecoupled event processors coupled event processorsnear-linear performance diminishing performance
![Page 35: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/35.jpg)
thread delegate patternthread delegate vs. consumer supervisor
![Page 36: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/36.jpg)
thread delegate patternthread delegate vs. consumer supervisor
scalability elasticityconsistent consumers variable consumersdecoupled event processors coupled event processorsnear-linear performance diminishing performancecan preserve message order message order not preserved
![Page 37: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/37.jpg)
Workflow Event Pattern
![Page 38: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/38.jpg)
workflow event pattern
responsive
resilient
message driven
elastic
how can you handle error conditions without failing the transaction?
![Page 39: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/39.jpg)
event consumer
event producer
workflow processor
workflow event patternhow can you handle error conditions without
failing the transaction?
![Page 40: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/40.jpg)
let’s see the issue…
workflow event pattern
![Page 41: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/41.jpg)
workflow event patternexample
while asynchronously processing trades an error occurs with one of the trade orders
trade processor
trading client
workflow processor
X
![Page 42: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/42.jpg)
let’s see the result…
consumer supervisor pattern
![Page 43: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/43.jpg)
Producer Control Flow Pattern
![Page 44: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/44.jpg)
producer control flow patternhow can you slow down message producers
when the messaging system becomes overwhelmed?
responsive
resilient
message driven
elastic
![Page 45: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/45.jpg)
event channel
event consumer
event producer
producer control flow patternhow can you slow down message producers
when the messaging system becomes overwhelmed?
flow monitor
slow down!
![Page 46: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/46.jpg)
producer control flow patternhow can you slow down message producers
when the messaging system becomes overwhelmed?
stop (broker) vs. slowdown (pattern)
![Page 47: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/47.jpg)
let’s see the issue….
producer control flow pattern
![Page 48: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/48.jpg)
producer control flow pattern
event channel
event consumer
event producer
flow monitor
wait for upper thresholdtell producers to slow downwait for lower thresholdtell producers to resume
![Page 49: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/49.jpg)
let’s see the result…
producer control flow pattern
![Page 50: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/50.jpg)
reactive patterns for self-healing systems
event producer
thread delegate
supervisorevent
dispatcherthread
delegate
event dispatcher
thread delegate
flow monitor
workflow processor
thread delegate pattern
consumer supervisor pattern
workflow event pattern
producer control flow pattern
![Page 51: SDD Reactive Architecture - SDD Conference...Reactive Architecture Patterns Independent Consultant Hands-on So*ware Architect Published Author / Conference Speaker Mark Richards h](https://reader036.vdocument.in/reader036/viewer/2022062402/5f94bf8edb2818188c06f6f0/html5/thumbnails/51.jpg)
Reactive Architecture PatternsIndependentConsultantHands-onSo*wareArchitectPublishedAuthor/ConferenceSpeaker
MarkRichards
h<p://www.wmrichards.comh<ps://www.linkedin.com/in/markrichards3@markrichardssa