Slide 1

Slide 1 text

Event Driven Architecture The Right Way! Bakare Emmanuel, DEIMOS ML @tiemmaBakare

Slide 2

Slide 2 text

I’m Bakare Emmanuel • Experienced Pipeline Plumber @DEIMOSML • DevOps and Linux Fan Boy • You can follow me on twitter @TiemmaBakare • General Weird Guy with some humour • People call me Bakman, so there’s also that! @ T i e m m a B a k a r e 2

Slide 3

Slide 3 text

3 What’s In For You? 1. 3-Tier Business 2. Monolith 3. Microlith (Bad design) 4. SPA / Backend -> Frontend 5. Microservices 6. Event Driven Applications a. Handlers to Events (1 to 1, no more) b. Events are to be unique and handled in no two ways 1. DEMO!!! 2. Event Sourcing and CQRS a. MemoryImage & ParallelModel b. Recording event data as it streams c. Event Logs and how they’re build 3. Event Collaboration 4. Retroactive Events 5. Resources YOU CAN COVER 2 - 4 FOR MORE INFO! HISTORY OF SOFTWARE ARCHITECTURES MORE BACKGROUND ON EVENT ARCHITECTURE

Slide 4

Slide 4 text

Definition Of Terms Frontend - The client and consumer of the requests we make, a frontend is the part of the entire thing that we interact with. A frontend could be a web browser, a load balancer, an api gateway etc. Backend: This is the main server that gets all the requests we push from the frontend. It is responsible for handling all the requests that we need to process. Tier - Basically a layer / part of the entire systems that interact with each other Microservice - This is basically a single service that does one thing and does it very well. Events - This is just a call to action, which has a subscriber and producer for handling it. PubSub - This means PublisherSubscriber and is related to systems that can read and write data in real time.

Slide 5

Slide 5 text

HISTORY OF SOFTWARE ARCHITECTURES

Slide 6

Slide 6 text

N-Tier Architecture (N = 1, 2, 3) This involves one, two, three parts of your application, all in order 1. Presentation Layer (Frontend e.g Vue) 2. Application Layer (Backend e.g Django, Flask, NodeJS) 3. Data Layer (Database, Persistence e.g Redis, Mongo, SQL)

Slide 7

Slide 7 text

Single, 2-Tier and 3-Tier Architectures Source: https://www.guru99.com/dbms-architecture.html

Slide 8

Slide 8 text

Monolith Says what it means, everything irrespective of the N number of tiers exists together. All parts of your application are bundled together and tightly integrated.

Slide 9

Slide 9 text

Microlith (Bad Design!!!) A mix of a monolithic service with queues in the middle masquerading as a microservice. Pick a Monolith or a Microservice, Don’t Pick Both

Slide 10

Slide 10 text

Microlith (Bad Design!!!) Source: https://dzone.com/articles/lagom-14-whats-new

Slide 11

Slide 11 text

SPA - Backend & Frontend SPA - Single Page Application This is a form of software architecture where the backend and frontend are detached. Requests are made using one-way or streaming connections and several backend functionality can be emulated on the frontend by local caching and routing. Examples are front ends on (service workers, PWAs, web components) using backends on (websockets / http/2 / gRpc / APIs) etc

Slide 12

Slide 12 text

Microservices This is basically a single service that does one thing and does it very well. So that means we can have a single service that does one thing. We could have a service for authentication, emails, transactions and whatever we feel needs to be singled out. It’s most preferred due to the fact that services can be rolled back and forward easily without directly bringing down the others. It’s also a lot more complex to orchestrate and requires fine understanding of the entire product. Directly - In the sense that an error there might bring down that service but the others that don’t need it work fine

Slide 13

Slide 13 text

Event Driven Application This is a type of application which functions on a pub-sub way of receiving data. In this kind of system, we can have multiple people publishing data to a queue and many subscribers reading the same data at the same time. This allows for a many to many call to action kinda API request. We publish and subscribe by using topics or channels. Whatever you use to call them, it’s just a simple pipe. What ever you send to it can be read on the other side at about the instant it’s sent, similar to a water pipe.

Slide 14

Slide 14 text

Event Driven Application Source: https://aws.amazon.com/pub-sub-messaging/ Multiple taps can read off the same pipe and many tanks can connect to one pipe.

Slide 15

Slide 15 text

Handlers to Events In event driven applications, we employ a concept of attaching handlers to events. A handler is just a fancy word for a function that reacts to that event. For those familiar with Javascript and the EventListener concept, you have an event and a callback function to handle it. That event and the function are uniquely bonded together.

Slide 16

Slide 16 text

Handlers to Events subscriber.on(‘event’, function(data) { …handle event data })

Slide 17

Slide 17 text

Events Are Unique And Handled Individually Events are always meant to be unique, the concept is to have a specific event attached to a specific action and ONLY that action, no duplicates. To properly group events that are similar, we use namespaces which is just simply attaching it in the following way: . ==== user.signup, email.send, folder.create etc.

Slide 18

Slide 18 text

Events Are Unique And Handled Individually subscriber.on(‘event’, function(data) { …handle event data }) subscriber.on(‘event’, function(data) { …another function to handle event data }) #wrong, same event as above

Slide 19

Slide 19 text

DEMO!!!

Slide 20

Slide 20 text

Resources Article title: What do you mean by “Event-Driven”? URL: https://martinfowler.com/articles/201701-event-driven.html Article title: MemoryImage URL: https://martinfowler.com/bliki/MemoryImage.html Article title: EventPoster URL: https://martinfowler.com/bliki/EventPoster.html Article title: Retroactive Event URL: https://martinfowler.com/eaaDev/RetroactiveEvent.html Article title: Parallel Model URL: https://martinfowler.com/eaaDev/ParallelModel.html Article title: Temporal Property URL:https://martinfowler.com/eaaDev/TemporalProperty.ht ml Article title: Tiemma/event-architecture-talk-pycon-node URL:https://github.com/Tiemma/event-architecture-talk-pyco n-node Article title: Event Collaboration URL: https://martinfowler.com/eaaDev/EventCollaboration.html Article title: Designing Events-First Microservices URL: https://www.youtube.com/watch?v=1hwuWmMNT4c&t=694s Article title: Four Distributed Systems Architectural Patterns by Tim Berglund URL: https://www.youtube.com/watch?v=tpspO9K28PM Article title: What is the difference between a monolithic architecture and a 3-tier architecture? URL:https://stackoverflow.com/questions/54965396/what-is-the- difference-between-a-monolithic-architecture-and-a-3-tier-archit ectu Article title: Tiemma/event-architecture-talk-pycon-python URL:https://github.com/Tiemma/event-architecture-talk-pyco n-python

Slide 21

Slide 21 text

QUESTIONS A good one would be what is your account number? Answer: 0041744115 UNION BANK, you can make a donation to my foundation for DevOps

Slide 22

Slide 22 text

DEIMOS Is Hiring!!! Software Engineers can apply here! Junior DevOps Engineers Senior Frontend Engineer Send an email with your CV to [email protected]