Cloud concept · Updated

Fan-Out - Fan-out is an architectural pattern in which one event, message, or request initiates processing by multiple downstream recipients or execution branches.

In short

Fan-out lets a producer trigger several independent activities without performing each activity itself. It supports parallel processing and independently scalable consumers, but requires deliberate handling of delivery failures, duplicate messages, ordering, and downstream capacity.

Cloud Concepts Hub →

6 key aspects of Fan-Out

Fan-out distributes one input across multiple processing paths while requiring independent scaling, reliable delivery handling, stable contracts, and branch-level visibility.

01
One input, multiple downstream activities

A single event or request initiates several processing paths. Use this when multiple applications need to react to the same business occurrence without making the producer call each application.

02
Independent delivery paths

Give each logical consumer its own subscription or queue when each must receive the event. Workers sharing one queue distribute work within a consumer application rather than create independent copies for different applications.

03
Parallelism and independent scaling

Branches can run concurrently and scale according to their individual workloads. Separate buffers help isolate slow consumers, but concurrency controls are still needed to protect shared databases and APIs.

04
Explicit failure and duplicate handling

One branch can succeed while another fails, so fan-out is not an all-or-nothing transaction. Implement idempotency, appropriate retries, dead-letter handling, and a policy for unresolved business failures.

05
Selective distribution and stable contracts

Filters route events only to interested consumers, reducing unnecessary processing. Version event schemas carefully so new consumers and producer changes do not break existing branches.

06
Branch-level observability

Track delivery failures, queue age, processing errors, and completion separately for each consumer. Carry event and correlation identifiers across branches to diagnose partial completion.

Cloud services for Fan-Out

A common design publishes business events to SNS and gives each consuming application its own SQS queue. Lambda functions or other workers process those queues independently, with separate retry and dead-letter policies. EventBridge provides another distribution approach when event matching and routing rules are central requirements; it can route matching events to queues, functions, or workflows. Step Functions coordinates parallel branches when the application must track their progress and wait for completion. Choose the combination according to routing, buffering, and coordination needs rather than assuming every fan-out architecture requires all of these services.

Amazon EventBridgeAmazon EventBridge

An EventBridge event bus uses rules to match events and route them to targets, allowing one event to initiate several downstream activities. It is useful when fan-out also requires content-based routing across application or AWS service events.

AWS LambdaAWS Lambda

Lambda functions can execute independent branches triggered through SNS, EventBridge, or dedicated SQS queues. Configure concurrency, retries, and failure handling for the specific invocation path because asynchronous invocation and queue polling have different processing behavior.

AWS Step FunctionsAWS Step Functions

Step Functions implements orchestrated branching through Parallel states and concurrent iteration through Map states. Use it when fan-out needs explicit workflow coordination, tracked branch outcomes, or a subsequent step that waits for branch completion.

Fan-Out exam questions

Real practice exam questions on Fan-Out, with the correct answer and its explanation. Answer them with every option in the exam simulator.

SAP-C03

An industrial monitoring company uses an AWS AppSync GraphQL API to send equipment alerts to browser consoles. All consoles subscribe to onAlert, which is associated with the publishAlert mutation through @aws_subscribe. Each console requests a different subset of the Alert type's fields. All fields in Alert are non-nullable.

An ingestion service durably stores each alert and then invokes publishAlert once for each connected console. Each invocation uses a mutation selection set matching that console's subscription selection set. The mutation resolver returns the complete stored alert. During testing, consoles receive repeated notifications for the same alert, and some notifications produce errors for missing non-nullable fields.

The company wants each alert publication to reach all currently subscribed consoles without generating duplicate publications. It also wants to remove the ingestion service's dependency on the number and identities of connected consoles. Network retries and reconnect recovery are outside the scope of this change.

Which change should a solutions architect recommend?

Show answerCORRECT ANSWER

Invoke publishAlert once per alert with a mutation selection set containing every field supported by the consoles' subscriptions. Allow each console to retain its own subscription selection set, and remove console enumeration from the ingestion service.

AppSync fans out a mutation result to matching subscribers; the producer does not invoke the mutation separately for each connection. Subscription selection sets must be subsets of the mutation's selection set. Publishing once with all required fields eliminates application-generated duplicate publications and supplies the fields needed by each console.

Practice Fan-Out in a full exam

Questions on Fan-Out in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Fan-Out

3 min read

Fan-out describes a one-to-many relationship: a single input causes multiple downstream activities. An order-created event, for example, might trigger inventory reservation, customer notification, and analytics ingestion. Each activity serves a different purpose, but all originate from the same business event. Fan-out can distribute the same event to multiple interested consumers or create several parallel execution branches from one request.

In cloud applications, a producer commonly publishes an event to a messaging topic or event bus. The messaging infrastructure routes it to subscribers or matching targets, so the producer does not need to call every consumer directly. Adding a new subscriber can introduce new behavior without changing the publishing code, provided the event contract already supplies the necessary information. This makes fan-out useful for event-driven microservices, although the pattern can also connect components within a larger application.

A practical AWS implementation uses an Amazon SNS topic with a separate Amazon SQS queue for each consuming application. An order service publishes once, and SNS delivers the message to each eligible queue subscription. Inventory workers process the inventory queue while notification workers process the notification queue. Each queue provides independent buffering, allowing one application to fall behind without forcing the other application to process at the same rate. Subscription filters can limit which events each application receives.

A critical distinction is that multiple workers reading one queue do not implement broadcast delivery to independent applications. Those workers are competing consumers: they share the processing workload rather than each receiving an independent copy of every message. If inventory and notifications must both process every order, give them separate subscriptions or queues. Multiple workers can then scale processing within each application's queue.

Fan-out improves concurrency and reduces direct coupling, but it does not make downstream work instantaneous or atomic. The order service may successfully publish while inventory processing later fails. Other branches might already have completed, so the overall business process needs an explicit policy for retries, compensation, or incomplete work. If a database update and event publication must remain consistent, a transactional outbox can address the dual-write problem; fan-out alone does not solve it.

Design consumers for the delivery guarantees of the selected infrastructure. Standard messaging configurations commonly permit duplicate delivery and do not guarantee ordering. Use stable event identifiers, idempotent operations, and conditional writes where appropriate to prevent duplicate business effects. Ordering and deduplication features have specific scopes and do not automatically guarantee exactly-once effects across databases or external APIs. Configure delivery retries and dead-letter handling separately from consumer-processing retries, and monitor failures at both stages.

Fan-out also multiplies traffic, processing, and cost. Estimate downstream work from the event rate and the number of matching recipients, then account for retries. Use buffering, concurrency limits, and backoff to protect constrained dependencies. Apply least-privilege publishing and subscription permissions, avoid unnecessarily distributing sensitive fields, and propagate correlation identifiers so engineers can trace one event across its branches.

For architectural-pattern questions, distinguish fan-out from choreography and orchestration. Fan-out describes how work branches; choreography describes services reacting to events without a central workflow coordinator, while orchestration uses a coordinator to control workflow progression. Either approach can contain fan-out. Fan-out also does not require collecting results: waiting for branches and combining their outputs adds fan-in or aggregation behavior.

Learn Fan-Out in lessons

4 short lessons on Fan-Out in 3 certification courses.

Open the lessons