Slide 1

Slide 1 text

WeAreDevelopers Live Days Remote, March 2021 Rethinking Reactive Architectures with GraphQL

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

Counter and Doubled should be bound.

Slide 6

Slide 6 text

the Destiny Operator Counter and Doubled should be bound. ⬅

Slide 7

Slide 7 text

1 map(x => x*2) 2 3 6 the Destiny Operator Counter and Doubled should be bound.

Slide 8

Slide 8 text

the Destiny Operator Counter and Doubled should be bound.

Slide 9

Slide 9 text

the Destiny Operator Counter and Doubled should be bound.

Slide 10

Slide 10 text

Stream Caller Receiver propagate change observe change The reactive programming paradigm is based on asynchronous streams which propagate change.

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 WeAreDevelopers! 👋 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

No content

Slide 17

Slide 17 text

The Reactive Manifesto Responsive Responsive NFR

Slide 18

Slide 18 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 did a decade ago.

Slide 19

Slide 19 text

The Reactive Manifesto Message Driven Responsive Elastic Resilient NFR Support Enable 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

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

Slide 24

Slide 24 text

Message Driven Responsive Elastic Resilient Value Form Means Microservice A Stream Microservice B

Slide 25

Slide 25 text

We are resilient by supporting Back-Pressure Stream Provider Consumer events are stored until consumed Stream Provider Consumer A Consumer C Consumer B scaling out consumers We can scale-out 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

Microservice A Microservice B Microservice C Web Application Microservice C with high latency First Generation MicroServices Synchronous and without Backpressure Support

Slide 28

Slide 28 text

Microservice A Microservice B Microservice C Web Application Microservice C with high latency Second Generation MicroServices Partially asynchronous with Queues Queue isolates bottleneck Queue Microservice C with high latency

Slide 29

Slide 29 text

Web Application Stream Microservice usually Backend-For-Frontend (BFF) Microservice A Microservice B Microservice C Third Generation MicroServices Fully asynchronous & stream-centric

Slide 30

Slide 30 text

Events as the System State Stream of Transactions Max sent David 100€ Max sent Maria 70€ David sent Maria 25€ User Balance David + 75 € Max - 170 € Maria + 95 € ➡ Event Sourcing 100% reliable audit log.

Slide 31

Slide 31 text

Web Application Stream Microservice usually Backend-For-Frontend (BFF) Microservice A Microservice B Microservice C

Slide 32

Slide 32 text

Web Application Eventstore Microservice usually Backend-For-Frontend (BFF) Microservice A Microservice B Microservice C

Slide 33

Slide 33 text

Web Application Eventstore Microservice usually Backend-For-Frontend (BFF) FaaS A FaaS B FaaS C Forth Generation MicroServices EventSourced with FaaS

Slide 34

Slide 34 text

FaaS A Web Application FaaS B FaaS C Eventstore Microservice often Backend-For-Frontend (BFF) HTTP Streaming Request/Response

Slide 35

Slide 35 text

GraphQL ✅ Consumer Driven APIs ✅ Native Schema Support ✅ Streaming Support

Slide 36

Slide 36 text

Streaming with GraphQL ➡

Slide 37

Slide 37 text

Lambda A Web Application Lambda B Lambda C Eventstore Microservice often Backend-For-Frontend (BFF) HTTP Streaming Request/Response

Slide 38

Slide 38 text

Lambda A Web Application Lambda B Lambda C Eventstore GraphQL Streaming Request/Response

Slide 39

Slide 39 text

Lambda A Web Application Lambda B Lambda C Eventstore GraphQL Microservice A Microservice B Microservice C Web Application ➡ pull-based push-based

Slide 40

Slide 40 text

Insurance Portal Example 🚗 👩💻

Slide 41

Slide 41 text

Lambda A Lambda B Lambda C 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 200 € 🏁 Sign Digital Do you accept 70% coverage for 200€? Eventstore GraphQL

Slide 42

Slide 42 text

GraphQL Step 1 Step 2 Step 2 Car Brand Build Year Car Model Lambda A Insurance Agent Lambda B Lambda C Eventstore GraphQL Customer ✅ This Is Correct Alfra Romeo Giulia, 2020 110PS, Diesel Step 1 Step 2 Step 2 Coverage 250 € 🏁 Sign Digital Do you accept full coverage for 250€? Customers expect realtime syncronisation between channels.

Slide 43

Slide 43 text

Mobile Banking Example 📱 💵

Slide 44

Slide 44 text

Mobile Banking Usage Show balance & last transactions: 93% Initiate new payment: 3% Any other functionality: 4%

Slide 45

Slide 45 text

Microservice A Web Banking Microservice B Microservice C Eventstore 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 46

Slide 46 text

Microservice A Web Banking Microservice B Microservice C Eventstore 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 47

Slide 47 text

GraphQL Mobile Client Projection Microservice A Web Banking Microservice B Microservice C Eventstore 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. Show balance & last transactions: 93%

Slide 48

Slide 48 text

The Reactive Manifesto Message Driven Responsive Elastic Resilient NFR Supported by Enabled by Scalability Extendibility

Slide 49

Slide 49 text

This stuff is cool, but think twice, & ensure that reactive architectures really fit your problem at hand.

Slide 50

Slide 50 text

Architectural Styles buy you options Reactive Architectures buy you mainly Resilience, Realtime Capabilities, Elasticity, & Extendibility. you pay by complexity. 💵

Slide 51

Slide 51 text

Maybe start small, and shift to reactive systems once needed.

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

@duffleit @duffleit [email protected] David Leitner Coding Architect

Slide 54

Slide 54 text

squer.link/kafka