Event Driven Architecture

1. Overview

1.1. Event-Driven Architecture (EDA):

  • EDA is a software architecture paradigm that promotes the production, detection, consumption of, and reaction to events.
  • Events can be defined as significant occurrences or changes in the system's state that can be originated internally or externally.
  • EDA is commonly used in systems where decoupled components need to communicate asynchronously.

1.2. Components of EDA:

  • Events: Key occurrences or changes to which the architecture is responsive. Events can trigger actions or workflows.
  • Event Producers: Entities that generate and publish events. They are responsible for notifying the system when something significant happens.
  • Event Consumers: Components that listen for and handle events. They react based on the event's information.
  • Event Channel/Bus: A medium through which events are transmitted from producers to consumers, often enabling a publish-subscribe model.
  • Event Processing: Logic that transforms or directs events as necessary to facilitate actions within the system.

1.3. Callbacks:

  • Callbacks are functions that are passed as arguments to other functions and are invoked once a specific event occurs or the task is complete.
  • They are primarily used for asynchronous operations, allowing a program to continue without blocking waiting for an event or result.

1.4. Hooks:

  • Hooks are predefined points within a system where custom code or functions can be inserted to influence the behavior of the system at runtime.
  • They allow for modification and extension of existing functionality without altering the core codebase, often used in plugin architectures.

1.5. Connections:

  • EDA uses both callbacks and hooks to efficiently manage and respond to events.
  • Callbacks provide a way to react to asynchronous events immediately, often simplifying the chaining of operations.
  • Hooks provide extensibility and customization, ensuring that various components or extensions can react to events by inserting additional logic.

2. Relevent Nodes

3. Diff b/w Request and Event Driven Architecure

3.1. *Request-Driven Architectures:

  • Operate on the basis of requests and responses, typically client-server models.
  • The flow of operations is initiated by a client request, leading to synchronous processing.
  • Suitable for operations requiring immediate feedback or results.
  • Often involves direct interaction patterns such as REST or RPC.

3.2. Event-Driven Architectures:

  • Operate on events that are emitted as significant state changes.
  • Asynchronous and decoupled, enabling components to react independent of each other.
  • Suitable for scenarios requiring real-time data processing and distributed system responsiveness.
  • Use indirect interaction patterns like message queues and publish-subscribe systems.

3.3. Key Differences:

  • Synchronous vs. Asynchronous: Request-driven is typically synchronous, while event-driven is inherently asynchronous.
  • Initiation: Request-driven is initiated by a specific client request, whereas event-driven is initiated by system or external events.
  • Decoupling: EDA emphasizes a higher level of decoupling between components than request-driven systems.
  • Scalability and Flexibility: EDA often provides greater scalability and flexibility, as components can evolve independently.
Tags::cs: