Patterns
35 items
35 items
Aggregating data from many sources into one destination
Fan-in is a messaging pattern where multiple producers send messages that are aggregated by a single consumer or processing point. It's the opposite of fan-out: many sources converge to one destination. This pattern is essential for aggregating data from distributed sources (collecting logs from thousands of servers), implementing scatter-gather (query multiple databases and combine results), and coordinating parallel work (waiting for all workers to complete). Fan-in reduces complexity by providing a single point for aggregation, correlation, and final processing.
Multiple producers send messages to a single consumer or aggregation point. This centralizes processing and simplifies downstream logic. Common in logging, metrics collection, and data pipelines.
Messages from different sources may arrive out of order. Fan-in often requires correlation IDs to group related messages and ordering logic to process them correctly.
When many producers send to one consumer, the consumer can become overwhelmed. Implement backpressure mechanisms: rate limiting, buffering, or flow control to prevent overload.
Distributed Search Example:
When a user searches on an e-commerce site: 1. Query goes to multiple index shards (fan-out) 2. Each shard returns partial results 3. Results must be merged, ranked, and paginated (fan-in)
Log Aggregation Example:
1000 servers each produce logs - Each server: 1000 log lines/second - Total: 1M log lines/second - Need central storage for querying and alerting
Without fan-in, you'd need to query each server individually or duplicate logs everywhere.