← Lessons

quiz vs the machine

Gold1460

System Design

The Aggregator Pattern

Collects related messages into a single combined result.

5 min read · core · beat Gold to climb

What it is

An aggregator is a stateful component that collects several related messages and combines them into one. It is the counterpart to a splitter, reassembling pieces that belong together.

How it works

  • Each incoming message carries a correlation id marking its group.
  • The aggregator holds messages until a completion condition is met.
  • It then emits a single combined message and clears that group.

Why it matters

  • Lets downstream steps act on a whole instead of fragments.
  • Combines responses from multiple services into one answer.
  • Bridges fine grained events into coarse grained results.

The hard part is deciding when a group is complete. Strategies include waiting for a known count, waiting until a timeout, or stopping on the first acceptable item. Because it holds state, an aggregator must handle late, missing, or duplicate messages, and it needs memory limits so an incomplete group does not grow forever.

Key idea

An aggregator gathers correlated messages and emits one combined result once a completion condition is satisfied.

Check yourself

Answer to earn rating on the learn ladder.

1. What signals the aggregator to emit its combined message?

2. Why must an aggregator be stateful?

3. What risk arises from a group that never completes?