Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event Driven Architecture - The Right Way

tiemma
November 01, 2019

Event Driven Architecture - The Right Way

Breaking out parts of your code that don’t need to run 24/7 on a full blown service will not only make debugging easier but will also optimize performance.

tiemma

November 01, 2019
Tweet

More Decks by tiemma

Other Decks in Programming

Transcript

  1. 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
  2. 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
  3. 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.
  4. 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)
  5. 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.
  6. 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
  7. 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
  8. 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
  9. 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.
  10. 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.
  11. 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: <EVENT_GROUP>.<EVENT_NAME> ==== user.signup, email.send, folder.create etc.
  12. 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
  13. 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
  14. 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
  15. DEIMOS Is Hiring!!! Software Engineers can apply here! Junior DevOps

    Engineers Senior Frontend Engineer Send an email with your CV to [email protected]