CONCEPT SHEET · Concepts

Event-Driven Architecture

One-liner: Services communicate by publishing facts (events) to a broker instead of calling each other; consumers react asynchronously and the system becomes eventually consistent.

ArticleConcepts© Arthur Bernier Jr512 words1 code block

Say this#

How it works#

TEXT
[Order Service] --OrderPlaced--> [Kafka topic: orders] --> [Inventory Svc]                                                        --> [Email Svc]                                                        --> [Analytics / warehouse]                                                        --> [Search indexer -> Elasticsearch]

Event sourcing + CQRS:

  1. Command → validate against current aggregate state → append events to the event store.
  2. Events published; projectors update read models (Postgres table, Redis, Elasticsearch).
  3. Queries hit read models only; writes never read from them.
  4. New requirement? Add a projector and replay history.

Reliability: publish via transactional outbox; consumers are idempotent; dead-letter queue for poison messages.

Trade-offs#

ChoiceProCon
Events vs sync RPCDecoupling, resilience to downstream outage, fan-out for freeEventual consistency, harder debugging, no immediate response
Event sourcingFull audit log, temporal queries, replaySchema evolution of old events, storage growth, learning curve
CQRSIndependent scaling and optimal models per sideTwo models to maintain, read lag
Fat eventsConsumers autonomousPayload bloat, duplicated data drift
Thin eventsSmall, always-freshCallback traffic, coupling to producer API

Numbers#

  • Kafka: millions of messages/s per cluster; single partition order of tens of MB/s and strictly ordered.
  • End-to-end event latency: typically 5-50 ms in-datacenter; read model lag usually sub-second.
  • Retention: Kafka default 7 days; event stores retain forever (compaction or snapshots).

In the interview#

See also