System ArchitectureSolution Architect

What is Event-Driven Architecture (EDA) and what problems does it solve?

Pass interviews with Hintsage AI assistant

Answer.

Event-Driven Architecture (EDA) is an approach in which system components interact through events: messages about changes or actions that have occurred. The system consists of event generators (producers), handlers (consumers), and a message bus (broker) that delivers events.

EDA allows for the creation of flexibly scalable, loosely coupled systems. Changes in one component do not require modifications to others: only the generation and processing of events.

Example code (event generation and handling in Node.js):

const EventEmitter = require('events'); class MyEmitter extends EventEmitter {} const emitter = new MyEmitter(); // Event handler emitter.on('userCreated', (user) => { console.log('User created:', user); }); // Event generation emitter.emit('userCreated', { id: 1, name: 'Ivan' });

Key features:

  • Ensures loose coupling between components
  • Easy to extend and modify the reaction logic to events
  • Requires quality design and monitoring of interactions

Trick questions.

Is EDA the opposite of microservices architecture?

No, they are not opposites. Microservices often use EDA for communication between services.

Can EDA be used only with message brokers?

Not necessarily. Local events (for example, through the Observer pattern) also implement EDA, but brokers allow for the construction of distributed systems.

Does EDA guarantee data immutability?

No. EDA is about component interaction; resilience to reprocessing (idempotency) and data consistency need to be implemented explicitly.