Mente

event_driven_architecture.htm

An event-driven architecture uses events to trigger and communicate between decoupled services and is common in modern applications built with microservices.

An event is a change in state, or an update, like an item being placed in a shopping cart on an e-commerce website. Events can either carry the state (the item purchased, its price, and a delivery address) or events can be identifiers (a notification that an order was shipped).

Event-driven architectures have three key components: event producers, event routers, and event consumers.

In Request/Response the API are the building blocks. In event-driven. data is the building block.

It's powered by Apache Kafka.

Why use it?

When to use?

![[Pasted image 20240618115255.png]]

Components

Pub/Sub Model

Architecture Patterns

The value of a pattern is telling you things to watch out for. Most systems have some form of these patterns.

  1. Event notification
    • A key element of event notification is that the source system doesn't really care much about the response
    • An application creates an event, that goes into a queue
  2. Event-driven state transfer
    1. Since we have more availability we have less consistency (eventual)
    2. We try to keep the data consistent across all services
  3. Event sourcing
    • Upsides
      • Auditing, debugging, historic state, alternative state, memory image
      • With more RAM we can do a lot more processes without using a database
    • Downsides
      • Unfamiliar, external systems, event schema, identifiers
    • You have logs and application state
    • You could rebuild the application state based on the logs
    • Version control is a form of event sourcing system (builds app state off log changes)
    • Another example is the accounting ledger
  4. CQRS (Command Query Responsibility Segregation)
    • You have a write component and a read component
    • Similar pattern is used in other databases (oltp and olap)

Design Patterns

Disadvantages

Azure

Service Bus vs. Event Grid

Azure Service Bus

Concepts

Queues

Topics

Namespaces

Resources

Videos

Books