Library / Case Studies
Deduplication at Segment
The single requirement of all data pipelines is that they cannot lose data. Data can usually be delayed or re-ordered–but never dropped.
By Segment engineers · Segment · Added 2026-10-12
All content belongs to Segment engineers / Segment. We only link to it and give credit. Report a problem
Learn this case study
About 37 min left. Your work is saved as you go.
What you are about to study
Segment explains a real system. You should know the basics: caching, queues and replication.
Ideas you will meet
- Event Driven Architecture
- Loosely coupled services reacting to events.
- Distributed Systems
- Consensus, time, failure and the fundamentals of scale-out.
What we already know about this
Our own lessons on these ideas. Read them here before you start, so it makes sense.
Messaging and Microservice Patterns · 12 minMessage brokers comparedQueues versus logs, and how Kafka, RabbitMQ, ActiveMQ, SQS, Pub/Sub and Pulsar differ, so you can pick one for a job.Read here
Why brokers
A message broker sits between producers and consumers so they do not need to be up at the same time, can run at different speeds and can scale separately. It gives you buffering (absorb bursts), decoupling, retries and fan-out. (The idea is introduced in the queues and async lesson of the foundations course.)
Two families
Queue-style broker Log-style broker Model Messages are routed to queues, delivered to a consumer, acknowledged and removed Messages are appended to a retained log; consumers track their own position Replay Not normally Yes: re-read from any retained offset Consumers Competing workers share one queue Several groups read the same log independently Ordering Per queue, loosened by competing workers Per partition Strengths Rich routing, per-message acks, priorities, delays Huge throughput, history, stream processing Examples RabbitMQ, ActiveMQ, Amazon SQS Kafka, Pulsar (also queue mode), Kinesis 100%Figure SDA-MSV-01-1 · Queue versus log · © forcsguy.com
The common brokers
- Kafka: distributed log; partitions give parallelism and per-key order; very high throughput; consumer groups; the foundation of many event pipelines and stream processors. More to operate (or use a managed service). Internals in the Kafka lesson of the advanced distributed systems course.
- RabbitMQ (and ActiveMQ): classic brokers speaking AMQP and other protocols. Exchanges route messages to queues by rules (direct, topic, fanout, headers). Per-message acknowledgements, priorities, delays and dead letter handling. Excellent for task queues and flexible routing at moderate scale.
- Amazon SQS: fully managed queue. Standard queues scale enormously with at-least-once delivery and best-effort ordering; FIFO queues keep order and deduplicate, at lower throughput. Visibility timeout and dead letter queues are built in. Pairs with SNS for fan-out.
- Google Pub/Sub (and similar cloud services): managed, global pub/sub with subscriptions, acknowledgement deadlines and optional ordering keys.
- Apache Pulsar: log-style with separated compute (brokers) and storage (BookKeeper), multi-tenancy, geo-replication, and both streaming and queue-style subscriptions.
Delivery guarantees
- At most once: may lose, never duplicates (acknowledge before processing). Fine for metrics.
- At least once: no loss, possible duplicates (acknowledge after processing); the practical default. Consumers must be idempotent.
- Exactly once: really means at-least-once delivery plus deduplication or transactions, available within some systems (for example Kafka transactions), but end-to-end it requires idempotent consumers or transactional sinks.
Choosing
100%Figure SDA-MSV-01-2 · Which broker family · © forcsguy.com
Need Lean towards Simple background jobs, no ops SQS or a cloud queue Flexible routing, priorities, delays RabbitMQ High-volume event streaming, replay Kafka or Pulsar Fan-out to many consumers in a cloud Pub/Sub or SNS plus queues Stream processing and joins Kafka with Flink or Kafka Streams Questions that decide it
How many messages per second, and how large? Do you need ordering (and by what key)? Do you need replay? How many independent consumers? What latency? Who will operate it? Start with the simplest tool that meets the needs; moving to a streaming platform when you truly need replay and scale is easier than operating one you did not need.
Real-world reading
Related reading
- Exactly-once Semantics Is Possible: Here's How Apache Kafka Does ItNeha Narkhede · ConfluentBlogs
- RabbitMQ TutorialsRabbitMQ · Broadcom / VMwareDocumentation
- Confluent Developer: Apache Kafka 101ConfluentCourses
- Confluent: Apache Kafka TalksConfluentYouTube
Show 6 moreShow fewer
- Apache Kafka DocumentationApache Kafka · Apache Software FoundationDocumentation
- Delaying Asynchronous Message Processing with RabbitMQ at IndeedIndeed engineers · IndeedCase Studies
- Confluent BlogConfluent engineers · ConfluentBlogs
- Kafka Source & DocsApache Software Foundation · apacheGitHub
- Deduplication at SegmentSegment engineers · SegmentCase Studies
- Kafka at LinkedInLinkedIn engineers · LinkedInCase Studies
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as Deduplication at Segment.
Warm upGet the vocabulary first.
Documentation
Apache Flink: Concepts overview
Stateful stream processing concepts: time, windows, state and fault tolerance.
Apache Software FoundationAdvanced
Books · Free from the author
Concurrent and Distributed Systems (Cambridge lecture notes)
Eight lectures on time, broadcast, replication, consensus and transactions, with notes, slides and video. Free from the author under CC BY-SA.
University of CambridgeIntermediate
WatchHow others solve the same problem, on video.
Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)
ReadEngineers explain it in their own words.
Papers
Kafka - Message Broker
Apache Kafka is a scalable message broker , and Apache Samza is a stream processing framework built upon Kafka. They are widely used as infrastructure for implementing personalized online services and real-time predic...
KleppmannIntermediate
Papers
Distributed Messaging, Queuing, and Event Streaming
This paper surveys the message brokers that are in vogue today for distributed communication. Their primary goal is to facilitate the construction of decentralized topologies without single points of failure, enabling...
ArxivIntermediate
See it in another companyThe same ideas, a different system.
Case Studies · Read here
Brooklin: Distributed Service for Near Real-Time Data Streaming at LinkedIn
Brooklin—a distributed service for streaming data in near real-time and at scale—has been running in production at LinkedIn since 2016, powering thousands of data streams and over 2 trillion messages per day. Today, w...
LinkedInIntermediate
Case Studies · Read here
Delaying Asynchronous Message Processing with RabbitMQ at Indeed
By implementing a delay queue for our message processing, we improved the resilience of our internal systems and were able to deliver jobs more reliably.
IndeedIntermediate
Read the codeSee how it looks when it is real.
GitHub
Awesome Microservices
Curated tools, frameworks and reading material for building microservice systems.
mfornosIntermediate
GitHub
Engineering Blogs
A huge directory of company engineering blogs to learn from real production systems.
kilimchoiIntermediate
Keep learning
Loading community…