Leveraging the
power of Reactive
Architectures
Microservices, Reactive and Distributed Systems Vienna
Vienna, August 2021
Slide 2
Slide 2 text
@duffleit
@duffleit
[email protected]
David Leitner
Coding Architect
Slide 3
Slide 3 text
Reactive?
Programming with, or designing upon,
asynchronous data streams.
Slide 4
Slide 4 text
asynchronous data streams.
Space
Time
Collections
Iterator Generator
Value
Getter Setter
Promise
Deferred Resolver
Stream
Reader Emitter
Slide 5
Slide 5 text
The relationship between them is implicit, an idea that only exists in the
mind of the programmers. It should be explicit, a part of the language,
and existing for all time. Counter and doubled should be bound.
Slide 6
Slide 6 text
the Destiny Operator
paulstovell.com/reactive-programming
Slide 7
Slide 7 text
1
map(x => x*2) 2
3
6
Reactive Programming,
is Programming with Streams.
Slide 8
Slide 8 text
No content
Slide 9
Slide 9 text
No content
Slide 10
Slide 10 text
C’mon, show me a
down-to-earth
example.
Slide 11
Slide 11 text
YAMS — Yet Another Mail Service
NEW 2021-04-11 — An important Email
2021-04-09 — Another important Email
2021-04-08 — Do you want to join my network?
2021-04-05 — Nigerian prince wants to send you money
X
your inbox contains 4 mails
1 NEW Mail
Reload
Controller
Rest Client
update UI Element
update UI
update UI
Slide 12
Slide 12 text
YAMS — Yet Another Mail Service
NEW 2021-04-11 — An important Email
2021-04-09 — Another important Email
2021-04-08 — Do you want to join my network?
2021-04-05 — Nigerian prince wants to send you money
X
your inbox contains 4 mails
1 NEW Mail
Reload Websocket Client
Email Email
count()
count()
collect()
filter()
subscribe
Email
map()
Slide 13
Slide 13 text
YAMS — Yet Another Mail Service
NEW 2021-04-11 — Hello Reactive Systems Vienna! 👋
2021-04-09 — Another important Email
2021-04-08 — Do you want to join my network?
2021-04-05 — Nigerian prince wants to send you money
X
your inbox contains 5 mails
2 NEW Mail
Websocket Client
Email Email
count()
count()
collect()
filter()
subscribe
Email
NEW 2021-04-11 — An important Email
map()
Slide 14
Slide 14 text
We move from a
pull-based design,
to an asynchronous
push-based design.
Slide 15
Slide 15 text
Reactive Programming
Reactive Architectures
We take the same concepts from reactive programming
and move them up to the system architecture.
Slide 16
Slide 16 text
“The Universal BBC Architecture”
Back in 2010…
Allard Buijze
Box Cylinder
Box
Slide 17
Slide 17 text
Internet has 4.7 Billion users.
Facbook has 2.8 Billion users.
Youtube has 2.1 Billion users.
2010
2020
The Internet has 1.4 Billion users.
A single website may
now handle twice as
much traffic as the entire
internet a decade ago.
Slide 18
Slide 18 text
No content
Slide 19
Slide 19 text
The Reactive Manifesto
Message
Driven
Responsive
Elastic Resilient
NFR
Supported by
Enabled by
Scalability Extendibility
Slide 20
Slide 20 text
Microservice A
Microservice B
Message
Driven
Responsive
Elastic Resilient
Value
Form
Means
Slide 21
Slide 21 text
Microservice A
Microservice B
Message
Driven
Responsive
Elastic Resilient
Value
Form
Means
Microservice B
Microservice B
Slide 22
Slide 22 text
Microservice A
Microservice B
Message
Driven
Responsive
Elastic Resilient
Value
Form
Means
Microservice B
Stream
Slide 23
Slide 23 text
Microservice A
Microservice B
Message
Driven
Responsive
Elastic Resilient
Value
Form
Means
requests pile up
Slide 24
Slide 24 text
Message
Driven
Responsive
Elastic Resilient
Value
Form
Means
Microservice A
Stream
Microservice B
Slide 25
Slide 25 text
We support
Back-Pressure Stream
Provider Consumer
events are stored
until consumed
Stream
Provider Consumer A
Consumer C
Consumer B
scaling out
consumers
We can horizontally scale by
Location Transparency
Slide 26
Slide 26 text
We move from a
synchronous pull-based
architecture, to an
asynchronous push-based
architecture.
Slide 27
Slide 27 text
Push, Pull,
Whaaaaaat?
Slide 28
Slide 28 text
Microservice A
Microservice B
Microservice C
Web Application
Slide 29
Slide 29 text
Microservice A
Microservice B
Microservice C
Web Application
Microservice C
with high latency
First Generation
Integrated Synchronous
without Backpressure Support
Slide 30
Slide 30 text
Microservice A
Microservice B
Microservice C
Web Application
Microservice C
with high latency
Second Generation
Partially Asynchronous &
Backpressure Support
Queue
isolates bottleneck
Queue
Slide 31
Slide 31 text
Web Application
Stream
Microservice
usually Backend-For-Frontend (BFF)
Microservice A
Microservice B
Microservice C
Thirds Generation
Stream Centric and
Fully Asynchronous
Slide 32
Slide 32 text
Events as the System State
Stream of Transactions
Max sent Tim 100€ Max sent Maria 70€ Tim sent Maria 25€
➡
Current Balance
Max
- 100€
Tim
+ 100€
Maria
+ 70€
- 170€ + 75€ + 95€
Stream-table duality
Slide 33
Slide 33 text
Web Application
Stream
Microservice
usually Backend-For-Frontend (BFF)
Microservice A
Microservice B
Microservice C
Migration via
Change-Data-Capture
Legacy
Database New User Added
User Updated
Change-Data-Capture
DB Log
Slide 34
Slide 34 text
www.squer.link/migration-strategies
Slide 35
Slide 35 text
Events as the System State
Stream of Transactions
Max sent David 100€ Max sent Maria 70€ David sent Maria 25€
Current Balance
Max
- 100€
David
+ 100€
Maria
+ 70€
- 170€ + 75€ + 95€
Stream-table duality
the truth,
the whole truth,
nothing but the truth.
Event Souring
Slide 36
Slide 36 text
Web Application
Stream
Microservice
usually Backend-For-Frontend (BFF)
Microservice A
Microservice B
Microservice C
Thirds Generation
Stream Centric and
Fully Asynchronous
Slide 37
Slide 37 text
Web Application
Eventstore
Microservice
usually Backend-For-Frontend (BFF)
Microservice A
Microservice B
Microservice C
Thirds Generation
Stream Centric and
Fully Asynchronous
Slide 38
Slide 38 text
Web Application
Eventstore
Microservice
usually Backend-For-Frontend (BFF)
Lambda A
Lambda B
Lambda C
Thirds Generation
Stream Centric and
Fully Asynchronous
Slide 39
Slide 39 text
Web Application
Stream
Microservice
usually Backend-For-Frontend (BFF)
Microservice A
Microservice B
Microservice C
Thirds Generation
Stream Centric and
Fully Asynchronous
Slide 40
Slide 40 text
Stream Centric Systems
are the only way to build
autonomous Microservices.
Slide 41
Slide 41 text
by: twitter.com/swardley
Slide 42
Slide 42 text
Stream Centric Systems
are the only way to build
autonomous Microservices.
Slide 43
Slide 43 text
Microservice A
Microservice B
Microservice C
UI
Slide 44
Slide 44 text
Account Summary Service
Transaction Service
User Service
Web Banking
Categorization Service
Config Service
The rise of the
Entity Service
Antipattern
High Presure
Low Resilience
Z
Y
X
Payment Service
Slide 45
Slide 45 text
Account Summary Journey
Transaction Service
User Service
Web Banking
Categorization Service
Config Service
The rise of the
Entity Service
Antipattern
High Presure
Low Resilience
Z
Y
X
Payment Journey
Paymet Customer Journeys
Account Overview Customer Journeys
Low service Autonomy
Weak Independent Deployability
Weak Independent Scalability
Slide 46
Slide 46 text
Account Summary Journey
Transaction Service
User Service
Web Banking
Categorization Service
Config Service
Payment Journey
projection
projection
We never write to projections,
we only read from them.
CQRS in a nutshell
websockets
Strong Service Autonomy at Runtime
Smaller Deployment Footprint
Good Horizontal Scalability
Account Summary Journey
projection
Slide 47
Slide 47 text
Lambda A
Web Application
Lambda B
Lambda C
Stream
GraphQL
Microservice A
Microservice B
Microservice C
Web Application
➡
pull-based push-based
Slide 48
Slide 48 text
www.squer.at
Slide 49
Slide 49 text
Focus on Realtime Integration
Insurance
Calculation
Slide 50
Slide 50 text
GraphQL
Step 1 Step 2 Step 2
Car Brand
Build Year
Car Model
Insurance Agent
Customer
✅ This Is Correct
Alfa Romeo Giulia, 2020
110PS, Diesel
Products
Users
Configurations
Eventstore
GraphQL
car brand has changed
Alfa Romeo
2020
Giulia, 110PS
Slide 51
Slide 51 text
GraphQL
Step 1 Step 2 Step 2
Car Brand
Build Year
Car Model
Insurance Agent
Alfa Romoe
2020
Giulia, 110PS
Customer
✅ This Is Correct
Alfa Romeo Giulia, 2020
110PS, Diesel
Step 1 Step 2 Step 2
Coverage
200 €
🏁 Sign Digital
Do you accept 70% coverage
for 200€?
Products
Users
Configurations
Eventstore
GraphQL
Slide 52
Slide 52 text
GraphQL
Step 1 Step 2 Step 2
Car Brand
Build Year
Car Model
Insurance Agent
Customer
✅ This Is Correct
Alfra Romeo Giulia, 2020
110PS, Diesel
Step 1 Step 2 Step 2
Coverage
250 €
🏁 Sign Digital
Do you accept 90% coverage
for 250€?
Products
Users
Configurations
Eventstore
GraphQL
Customers expect
realtime syncronisation
between channels.
Slide 53
Slide 53 text
Focus on Resilience
High
Available
Banking
Slide 54
Slide 54 text
Mobile Banking Usage
Show balance & last transactions: 93%
Initiate new payment: 3%
Any other functionality: 4%
Slide 55
Slide 55 text
Transactions
Web Banking
Users
Accounts
Stream
GraphQL
Projection
Projections
1⃣ Projections act as read-models for a specific client.
2⃣ They subscribe to events & hydrate the projection.
3⃣ The client only reads from the projection.
Slide 56
Slide 56 text
Transactions
Web Banking
Users
Accounts
Stream
GraphQL
Projection
Projections
1⃣ Projections act as read-models for a specific client.
2⃣ They subscribe to events & hydrate the projection.
3⃣ The client only reads from the projection.
Projection
Slide 57
Slide 57 text
GraphQL
Mobile Client
Projection
Transactions
Web Banking
Users
Accounts
Stream
GraphQL
Projection
Projections
1⃣ Projections act as read-models for a specific client.
2⃣ They subscribe to events & hydrate the projection.
3⃣ The client only reads from the projection.
Only one hard problem in
computer science left. 😎
Projection
Show balance & last transactions working,
93% of customers still happy.
With a concept like
optimistic UIs even more.
Slide 58
Slide 58 text
lousy memes
Ok let‘s
sum up!
lousy memes
within lousy
memes
High Resilience &
Scalability
Slide 59
Slide 59 text
Architectural Styles always
buy you options.
This stuff is cool,
Reactive Architectures buy you Resilience,
Realtime Capabilities, Elasticity, & Extendibility.
you pay by complexity.
💵
e.g. perpetual, or eventual inconsistency
Slide 60
Slide 60 text
Maybe start small,
and shift to reactive systems once needed.
Slide 61
Slide 61 text
by: twitter.com/swardley
Slide 62
Slide 62 text
@duffleit
@duffleit
[email protected]
David Leitner
Coding Architect
squer.at/slides
this presentation