Choosing the Right Kafka Partition Strategy: Key vs. Round-Robin vs. Sticky
Master Kafka partition strategies for the CCDAK exam. Learn when to use key-based, round-robin, or sticky partitioning with practical examples and exam tips.
Master Kafka partition strategies for the CCDAK exam. Learn when to use key-based, round-robin, or sticky partitioning with practical examples and exam tips.
Partitioning is one of the most basic concepts in Apache Kafka and an important topic in the CCDAK certification exam. While many developers understand that Kafka topics are split into partitions, fewer can clearly explain how partition strategies affect ordering, throughput, scalability, and consumer behavior, all areas that CCDAK explicitly tests.
In this article, we will explain three main Kafka partition strategies:
By the end, you should be able to confidently choose the correct strategy in both production systems and CCDAK exam scenarios.
In Kafka, partitioning is not an implementation detail, it directly determines:
CCDAK questions often describe a realistic use case and ask you to identify the correct producer configuration or partitioning approach. Simply memorizing definitions is not sufficient, you must understand trade-offs.
A Kafka topic is divided into partitions, each of which is an ordered, immutable log. Ordering is guaranteed only within a single partition, not across the entire topic.
When a producer sends a record, Kafka must decide which partition that record belongs to. This decision is made by the partitioner, based on:
Kafka producers typically use one of three partition strategies:
Each strategy optimizes for different goals. CCDAK expects you to recognize which strategy best fits a given scenario, not which one is "best" overall.
When a producer sends a record with a key, Kafka uses the murmur2 hash algorithm and maps it deterministically to a partition:
partition = murmur2(key) % number_of_partitions
All records with the same key will always go to the same partition, as long as the partition count remains unchanged.
Advantages of Key-Based Partitioning
Disadvantages of Key-Based Partitioning
In CCDAK questions, key-based partitioning is usually the correct answer when:
A common exam trap is choosing round-robin when ordering is implicitly required. If the scenario mentions "events must be processed in order", key-based partitioning is almost always expected.
With round-robin partitioning, the producer sends each record to the next partition in sequence:
Round-robin is appropriate in CCDAK scenarios where:
However, CCDAK often expects you to recognize that round-robin is suboptimal for performance in modern Kafka clients. If throughput optimization is mentioned, sticky partitioning is usually the better choice.
Sticky partitioning improves on round-robin by temporarily "sticking" to a partition and sending multiple records to it before switching.
Key characteristics:
Sticky partitioning dramatically improves throughput by maximizing batch efficiency. Round-robin forces the producer to maintain separate, partially-filled batches for every partition, causing frequent flushes of small batches. Sticky partitioning fills batches completely before switching partitions, reducing request count and network overhead by 30-50%, which is a critical performance difference CCDAK expects you to recognize.
Sticky partitioning is a high-value CCDAK topic because:
If an exam question mentions high throughput, producer efficiency, or batching, sticky partitioning is usually the correct choice.
A crucial exam concept: null keys trigger non-deterministic behavior.
When a producer sends a record with a null key, the partitioner automatically uses sticky (or round-robin in legacy clients) regardless of your data semantics. Many CCDAK questions imply "no key exists" without stating it directly, so watch for phrases like "independent events" or "no ordering requirement" as signals to use sticky partitioning.
When partition counts change, key-based partitioning breaks down. Adding partitions from 6 to 8 remaps keys because murmur2(key) % partitionCount produces different results. This destroys ordering guarantees and corrupts stateful operations. CCDAK tests this trap explicitly, so always consider partition count stability when choosing key-based strategies. The only safe expansion methods are custom partitioners.
| Strategy | Ordering Guarantee | Load Balance | Throughput | CCDAK Use Case |
|---|---|---|---|---|
| Key-Based | Per key | Variable (risk of hot partitions) | Medium | Stateful processing |
| Round-Robin | None | Excellent short-term | Low-Medium (30-50% lower than sticky) | Simple stateless data (pre-2.4 clients) |
| Sticky | None | Excellent long-term | High (30-50% better than round-robin) | High-throughput producers |
Use this decision framework in the exam:
CCDAK questions often hide the requirement in subtle wording, so read carefully.
To strengthen your CCDAK readiness, continue studying:
Explore more CCDAK-focused Kafka articles on ccdak-certification.com to build exam-ready intuition and confidence.
This guide covered the fundamentals, but passing requires mastering the edge cases, configuration nuances, and real-world scenarios that trip up most candidates.
150+ pages covering every exam objective with real-world examples and zero filler content.
300+ exam-style scenarios with detailed explanations that teach you the why behind every answer.
Authentic exam questions covering all domains with detailed explanations.
Quick-reference guides for configurations, APIs, and patterns—perfect for last-minute revision.
Stay current with updates delivered whenever new content and features are released.
No 40-hour video courses. Focused content that gets you exam-ready in weeks, not months.
150+ pages, 600+ practice questions, 300+ exam questions, 5+ cheat sheets. One-time payment, lifetime value.
Published on January 22, 2025
Back to All Articles