Introduction

Event-driven architecture is a style in which the components of a system communicate through events rather than by calling one another directly. An architectural style is a general approach to how the parts of a system are arranged and interact. An event is a structured record that describes something that has already happened, for example an order that has been placed. This guide explains what event-driven architecture is, why it exists, how it operates, and the situations in which it is appropriate.

What is it?

In an event-driven system, a component that detects a change publishes an event, and other components react to that event. The component that publishes an event is called a producer. A component that reacts to an event is called a consumer. The producer and the consumer do not call each other directly. Instead, events are delivered through an intermediary that is often called an event router or event broker. Because the producer does not know which consumers will react, the components are said to be loosely coupled. Coupling is the degree to which one component depends on another.

Why does it exist?

When components call one another directly and wait for a reply, they become tightly coupled. If one component is slow or unavailable, the components that depend on it are affected, and adding new behavior often requires existing components to be modified. Event-driven architecture was adopted so that components could be decoupled. A producer emits an event and continues its work, and any number of consumers can react independently. New consumers can be added without the producer being changed, which improves scalability, resilience, and extensibility.

How it works

A producer emits an event to an event router, and the router delivers the event to the interested consumers. On AWS, several services perform the routing role. Amazon EventBridge is an event bus that routes events according to rules. An event bus is a channel through which events are sent and matched to targets. Amazon Simple Notification Service, known as Amazon SNS, delivers a message to many subscribers at once, a pattern called fan-out. Amazon Simple Queue Service, known as Amazon SQS, holds messages in a queue until a consumer is ready to process them. A queue is a buffer that stores messages in order of arrival.

Two coordination patterns are common. In choreography, each consumer reacts to events on its own and no central controller exists. In orchestration, a central workflow directs the sequence of steps, a role for which AWS Step Functions is often used.

Architecture diagram

Producer Event router Consumers (a service that --> (EventBridge bus, --> (Lambda functions detects a SNS topic, or or other services change) SQS queue) that react) | v Failed messages are sent to a dead-letter queue

Advantages

Disadvantages

Common use cases

Best practices

Common mistakes

Further reading in this library

Frequently Asked Questions

What is an event in event-driven architecture?
An event is a structured record that describes something that has already happened, for example an order that has been placed. An event states a fact about the past and does not instruct any particular component to act.
How does event-driven architecture differ from request and response?
In request and response, one component calls another directly and waits for a reply, which couples the two together. In event-driven architecture, a producer emits an event without knowing which components will react, and consumers respond independently.
What is the difference between choreography and orchestration?
In choreography, each component reacts to events on its own and no central controller exists. In orchestration, a central workflow directs the sequence of steps. AWS Step Functions is commonly used for orchestration.
What is a dead-letter queue?
A dead-letter queue is a separate queue to which a message is moved after it has failed to be processed a set number of times. It prevents endless retries and preserves the message so the failure can be investigated.
Is the order of events guaranteed?
Not always. Ordering depends on the service that is used. Consumers should be designed so that events that arrive out of order or more than once are handled correctly.
AWS Serverless Architecture Handbook cover
Go deeper ยท Book as a Service™
AWS Serverless Architecture Handbook

This article is the summary. The book is the full, continuously updated reference: event-driven patterns, messaging services, error handling, and complete serverless architectures.

View the book