Library / Blogs
REA Group Engineering Blog
Learn from REA Group's brightest tech minds as they share what's happening in the technology space.
By REA Group engineers · REA Group · Added 2026-10-12
All content belongs to REA Group engineers / REA Group. We only link to it and give credit. Report a problem
Learn this article
About 37 min left. Your work is saved as you go.
What you are about to study
REA Group wrote this to explain how they thought about a problem. You should know the basics: caching, queues and replication.
Ideas you will meet
- 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.
Advanced Distributed Systems · 13 minKafka internals: segments, replication and consumer groupsWhat is inside a topic: partitions as append-only logs split into segments, how followers keep copies, and how consumer groups share the work.Read here
A topic is a set of logs
A Kafka topic is split into partitions. Each partition is an append-only log: new records go on the end and get an increasing offset. Order is guaranteed only within a partition; records with the same key go to the same partition, so per-key order holds. Consumers track how far they have read by offset. (Why this design is fast is covered in the "Why is Kafka fast" lesson.)
On disk: segments
A partition's log is stored as a series of segment files. The newest segment is the one being written; older segments are immutable. Each segment has companion index files that map offsets (and timestamps) to positions in the file, so a consumer can jump to an offset quickly.
- Retention is applied by deleting whole old segments (by age or total size), which is cheap.
- Compaction (for some topics) keeps only the latest record per key, turning the log into a changelog of current state.
100%Figure SDA-ADS-03-1 · Partitions, segments and replicas · © forcsguy.com
Replication and durability
Each partition has a replication factor (commonly 3): one leader and followers. Followers fetch from the leader. The in-sync replicas (ISR) are the followers that are caught up.
A producer chooses an acknowledgement level:
Setting Meaning Trade-off acks=0Do not wait Fastest, may lose data acks=1Leader has written it Loses data if the leader fails before replicating acks=allAll in-sync replicas have it Safest, slower With
acks=alland a minimum in-sync replicas setting, a write succeeds only if enough copies exist, trading availability for durability. If the leader fails, a new leader is chosen from the in-sync replicas, so acknowledged writes survive. (Older versions used ZooKeeper for cluster metadata; newer ones use a built-in Raft-based controller; the idea of consensus on metadata is the same as in the consensus lesson.)Consumer groups and rebalancing
Consumers sharing a group id split a topic's partitions: each partition is read by one member at a time, so parallelism is limited by the number of partitions. Different groups each read the full topic independently.
100%Figure SDA-ADS-03-2 · Consumer group rebalance · © forcsguy.com
Offsets are committed back to Kafka. Commit after processing for at-least-once delivery (duplicates possible, so make consumers idempotent). Rebalances happen when members join, leave, crash or are too slow (missing heartbeats or taking too long to poll). Frequent rebalances hurt throughput, so keep processing per batch short and group membership stable.
Practical rules
- Partition count is a design decision: it caps consumer parallelism, and increasing it later changes the key-to-partition mapping.
- Key choice controls ordering and balance: pick a key with many distinct values.
- Monitor consumer lag per partition, under-replicated partitions and request latency.
- Idempotent producers and transactions exist for stronger guarantees (exactly-once within Kafka); end-to-end exactly-once still needs idempotent consumers or transactional sinks.
- Stream processing (Kafka Streams, Flink) builds on the same consumer mechanics; see the big-data platforms course.
Real-world reading
Related reading
- Exactly-once Semantics Is Possible: Here's How Apache Kafka Does ItNeha Narkhede · ConfluentBlogs
- Kafka Source & DocsApache Software Foundation · apacheGitHub
- Confluent Developer: Apache Kafka 101ConfluentCourses
- Confluent: Apache Kafka TalksConfluentYouTube
Show 6 moreShow fewer
- Jordan Has No Life: Systems Design Concepts SeriesJordan · Jordan Has No LifeYouTube
- Apache Kafka DocumentationApache Kafka · Apache Software FoundationDocumentation
- Apache CassandraApache Software Foundation · GitHubGitHub
- Cassandra architecture overviewApache Cassandra · Apache Software FoundationDocumentation
- REA Group Engineering BlogREA Group engineers · REA GroupBlogs
- Repo-Topix: Topic Extraction Framework at GithubGithub engineers · GithubCase Studies
Go deeper on this
A path through videos, articles, other case studies and code on the same ideas as REA Group Engineering Blog.
Warm upGet the vocabulary first.
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
Books · Free from the author
Computer Networks: A Systems Approach
How networks are built and why: protocols, routing, congestion control and the internet's architecture. The authors publish it free online under CC BY 4.0.
Systems ApproachIntermediate
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.
Blogs · Free from the author · Read here
Scalable Web Architecture and Distributed Systems
A full chapter on the building blocks of large websites: availability, performance, reliability, scalability, caches, proxies, indexes, load balancers and queues. Free to read here under CC BY 3.0.
The Architecture of Open Source ApplicationsBeginner40 min
Papers · Read here
Facebook’s photo storage
This paper describes Haystack, an object storage system optimized for Facebook’s Photos application. Facebook currently stores over 260 billion images, which translates to over 20 petabytes of data.
USENIXIntermediate
See it in another companyThe same ideas, a different system.
Case Studies · Read here
Aroma: Using ML for Code Recommendation at Facebook
Thousands of engineers write the code to create our apps, which serve billions of people worldwide. This is no trivial task—our services have grown so diverse and complex that the codebase contains…
FacebookIntermediate
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
Read the codeSee how it looks when it is real.
GitHub
Engineering Blogs
A huge directory of company engineering blogs to learn from real production systems.
kilimchoiIntermediate
GitHub
Awesome Scalability
Curated reading list of articles on the architecture of scalable, reliable systems.
binhnguyennusIntermediate
Keep learning
Loading community…