How Many Kafka Partitions? Count, Consumers & Sizing
Take the larger of 2 numbers: the partitions your producers need, and the partitions your consumers need to hit the target throughput. Then round up to a count your consumer group sizes divide evenly. The partition count is also the most consumers a group can use, so extra consumers sit idle, and you can raise it later but never lower it.
How many partitions should a Kafka topic have?
Pick the larger of 2 numbers: the partitions your producers need to reach the target throughput, and the partitions your consumers need to keep up with it. Round up to a count your planned consumer group sizes divide evenly, and leave room for growth, because the count can be raised later but never lowered. A topic created with no count gets 1 partition from the broker default num.partitions.
A partition is the unit of parallelism in Kafka. It's an ordered log that lives on 1 broker as leader, and it's read by at most 1 consumer of a consumer group at a time. So the partition count caps how many consumers a group can use, sets how write and read load spread across brokers, and defines the scope of ordering, since order holds only inside 1 partition.
Know Kafka partition count the way the interviewer who asks it knows it.
Partitions vs consumers: why extra consumers sit idle
The Apache Kafka design documentation says each partition is consumed by exactly 1 consumer within each subscribing consumer group at any given time. A group of 3 consumers on a topic with 6 partitions gives each consumer 2. Add consumers and the load spreads thinner, up to 1 partition each.
Past that point more consumers add nothing. A group of 8 consumers on 6 partitions has 2 consumers with no partition: they join the group but hold no assignment, standing by to take over if a busy consumer fails. The partition count is therefore the ceiling on a group's useful size: a group can have fewer consumers than partitions, never more doing work.


Separate consumer groups don't compete. Each group reads every partition on its own, so a second application reading the same topic adds no constraint on the first, and each group's ceiling is the same partition count.
How to size the partition count from throughput
Where the per-partition rates come from
The 2 rates are measurements, not constants, and the example values (10 MB/s and 5 MB/s) are assumptions to replace with your own. Measure the producer rate against a topic with 1 partition, using your real record size and your batching and compression settings. Measure the consumer rate with the real processing code, because the slowest step usually sits after the read: a database write or an API call, not Kafka.
In the example the consumer side decides: 12 partitions would carry the writes, but consumers at 5 MB/s per partition need 24. When the consumer side is the larger number, the cheaper fix is often a faster consumer, since halving the processing cost per record halves the partitions needed. Take the count from the faster consumer only if you've measured that it exists.
Plan for the peak you expect over the life of the topic, not today's average. Since the count can be raised later at a cost to key ordering, a modest margin of 1.5x to 2x on the computed number is a reasonable place to start, and a number that is several times larger buys nothing but overhead.
Choose a count your consumer group sizes divide evenly
Partitions are handed out whole, so a count that does not divide by the group size leaves some consumers with more. With 24 partitions, a group of 6 consumers gives each 4 partitions and a group of 8 gives each 3. A group of 10 gives some consumers 3 and others 2, so its busiest consumer carries the same 3 as a group of 8 and the 2 extra consumers buy no relief.
The busiest consumer sets the group's pace, because it falls behind first. A count with many divisors, such as 24, lets the group grow through 2, 3, 4, 6, 8 and 12 consumers with an even split each time. A prime count like 13 or 23 splits evenly only at 1 consumer or at 1 per partition. Idle consumers appear when a group is larger than the count: 4 idle at 28 consumers on 24 partitions.
Partition count, keys and ordering
Kafka guarantees that a consumer reads a topic-partition's events in the order they were written, and that events with the same key go to the same partition. That gives per-key ordering, for example every event for 1 customer in sequence, and none across keys. If a topic needs 1 global order, it needs 1 partition and at most 1 active consumer per group, which caps its throughput at what 1 partition carries.
The key-to-partition mapping depends on the count. The Apache Kafka operations documentation warns that with the default partitioner, which uses a hash of the key modulo the number of partitions, raising the count changes the mapping, so messages with the same key may route to different partitions after the expansion and per-key ordering can break for existing keys. Kafka doesn't redistribute existing data.
The same page states that Kafka does not currently support reducing the number of partitions for a topic. Together these make the count a one-way decision for any topic whose consumers depend on key order or keep per-key state: pick it with growth in mind, or plan a new topic and a migration. A topic whose consumers keep no per-key state can grow with little trouble.
Create a topic and add partitions
# create a topic with 24 partitions
bin/kafka-topics.sh --bootstrap-server localhost:9092 \
--create --topic orders --partitions 24 --replication-factor 3
# see the partition count and each partition's leader
bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic orders
# raise the count (it can never be lowered)
bin/kafka-topics.sh --bootstrap-server localhost:9092 \
--alter --topic orders --partitions 48Raising the count changes where a key hashes to, so existing keys can move partitions
What too many partitions costs
A producer keeps a batch per partition it writes to, sized by batch.size (16,384 bytes by default), all drawn from buffer.memory (33,554,432 bytes by default), enough for 2,048 full batches. A consumer can fetch up to max.partition.fetch.bytes per assigned partition, 1 MiB by default, so its memory use grows with the partitions it owns. Brokers keep files and replicas for each partition.
Spreading the same traffic over more partitions also makes each batch smaller, since a producer fills 1 batch per partition and sends it when it's full or when linger.ms expires. Smaller batches mean more requests for the same bytes. A topic with far more partitions than the throughput needs pays these costs for nothing, so choose the smallest count that meets the sizing and consumer targets with some margin.
The Kafka settings that interact with partition count
num.partitionsbatch.sizebuffer.memorymax.partition.fetch.bytesHow partition count comes up in data engineering interviews
Interviewers ask this as a design question: pick a partition count for an event stream and defend it. A strong answer gives the throughput arithmetic from both sides, names the key that preserves order, states the consumer group ceiling and says how to change the count later and what that breaks. It works as a short calculation to practice, so run the sizing formula with your own numbers.
Kafka questions show up across the Kafka interview questions set and in design rounds. The data pipeline interview questions and data pipeline practice problems cover the streaming pipelines these partitions feed, and the data engineer interview prep guide maps the rest of the loop. For the basics of topics, producers and brokers, see the Kafka tutorial.
Kafka partitions FAQ
How many partitions should a Kafka topic have?+
What is the default number of partitions?+
What happens when there are more consumers than partitions?+
Can I increase the number of partitions of an existing topic?+
Can I reduce the number of partitions?+
Is more partitions always better?+
Do partitions guarantee ordering?+
The candidate who gets the offer
- 01
Reading a solution is not the same as writing one
Every engineer who has frozen on a query they had read a dozen times knows the gap. The only preparation that closes it is producing the answer yourself, under time, before the interview does it for you
- 02
76% of hiring managers reject on the coding task, not the resume
From HackerRank's 2024 Developer Skills Report. Candidates who look strong on paper still fail the live screen if they haven't done timed, executable practice
- 03
System design comes down to the calls you defend out loud
Ingestion, batch vs streaming, the bronze/silver/gold layers, idempotency, backfill and replay. Sketching the pipeline and naming the failure modes is the signal, not the boxes
Related guides
Data pipeline interview questions
Streaming and batch pipeline design questions interviewers ask
Data pipeline practice problems
Pipeline design problems to practice before the loop
Kafka interview questions
Questions on topics, partitions, consumer groups and delivery
Data engineer interview prep
How to prepare for every round of the loop
Kafka tutorial
Topics, producers, consumers and brokers from the start
Kaggle for data engineering
Where Kaggle helps a data engineer and where it stops
Data engineering YouTube channels
Channels worth watching for streaming and pipeline topics
Compete in the Weekly
Dirty, production-shaped data, scored blind each week.