Kafka Partitions: Keys, Replication & Scaling Trade-Offs

Serdar Tekin
Serdar Tekin
Co-Founder & CTO
Updated Oct 31, 202615 min read
Written for: Developers, founders, and small platform teams choosing Kafka partition keys, partition counts, replication, and scaling strategy for production workloads
KafkaKafka PartitionsPartition KeysReplicationEvent StreamingManaged Databases
Last reviewed:
Guide
Kafka Partitions: Keys, Replication & Scaling Trade-Offs
rafftechnologies.com/learn
On this page

Key Takeaways

Kafka partition keys should match the smallest business ordering domain that must stay consistent. Partition count should follow required consumer concurrency, traffic distribution, and growth rather than a universal throughput rule. Hot partitions are often caused by skewed keys, so adding partitions may not fix a dominant ordering domain. Replication factor protects partition availability but does not increase application-level partition parallelism. Increasing partitions later can change key routing, while Kafka does not support reducing partition count.

Don’t have a server yet?

Kafka partitions are ordered log segments that divide a topic into independent units for storage, ordering, replication, and parallel processing.

The important design decision is not whether to use partitions; every Kafka topic is partitioned. It is how many partitions the topic should have, which record key should control placement, and how replication should protect those partitions without confusing fault tolerance with application parallelism.

Partition count should be treated as an application design decision before it is treated as a broker tuning parameter. A poor key can create hot partitions even in a large cluster, while an oversized partition count can add operational complexity without fixing the actual bottleneck.

For the broader event-streaming model, see Kafka Architecture for Small Teams. Here the key decisions concern partition keys, partition count, skew, replication factor, and how scaling affects record order.

Kafka partitions define the unit of order and parallel work

A Kafka topic can contain multiple partitions, and each partition is an ordered sequence of records. Kafka preserves record order within a partition rather than across the entire topic.

That makes a partition two things at once:

  • an ordering boundary for related events; and
  • a parallelism boundary for producers, brokers, and consumer work.

The architecture consequence is simple: adding partitions can create more independent work, but it also creates more places where ordering, replication, placement, recovery, and monitoring must be understood.

The current Apache Kafka introduction describes topics as partitioned across brokers for scalability and notes that records with the same key are written to the same partition. That same-key behavior is why partition design starts with event correctness rather than a target partition number.

The key question is what should determine the partition boundary for this workload?

Partition keys define the ordering domain

A partition key should represent the entity whose events need to remain together for ordered processing.

Examples can include:

  • an account ID when account events must remain ordered;
  • an order ID when each order has an independent event sequence;
  • a device ID for telemetry that must be processed in device order;
  • a tenant ID only when tenant-wide ordering is genuinely required.

The key should match the smallest business ordering domain that must remain consistent. Choosing a broader key than necessary reduces distribution. Choosing a key unrelated to the real ordering requirement can spread dependent events across partitions and move the ordering problem into the application.

Key cardinality also matters. A key with many reasonably distributed values can spread work across partitions. A key with only a few dominant values can concentrate traffic even when the topic has many partitions.

This creates a useful test:

Key questionGood signalRisk signal
Does the key match the required ordering boundary?dependent events share a keydependent events can land separately
Are there enough distinct keys?many active values can distributevery few values dominate traffic
Is traffic reasonably balanced across keys?no single entity dominatesone tenant, account, or device dominates
Will the key remain stable?key semantics persist over timekey definition may change with product logic

At Raff, we treat the partition key as a correctness decision first, distribution decision second. More partitions cannot repair a key that funnels most of the workload into one ordering domain.

Partition count should follow concurrency, traffic, and growth

There is no universal correct partition count for a Kafka topic.

The count should be large enough for the required parallelism and expected growth, but not chosen from an arbitrary rule such as “more partitions are always better.”

Use four inputs:

  1. Required ordering. How many independent ordering domains can safely run in parallel?
  2. Consumer concurrency. How many consumers may need to process this topic concurrently within one consumer group?
  3. Traffic and storage distribution. Does the workload need more independent shards to spread sustained work?
  4. Growth headroom. How likely is the topic to require more parallelism later?

Partition count matters because one partition is assigned to at most one active consumer within a consumer group at a time. Ten consumers cannot create ten-way partition-level parallelism on a four-partition topic.

The reverse matters too. Creating hundreds of partitions for a workload that needs only a few independent workers adds metadata, replica placement, leadership, recovery, and monitoring surface without necessarily improving the application.

Do not use a fabricated “messages per second per partition” rule. Real capacity depends on record size, compression, acknowledgements, replication, storage, network, producer batching, consumer behavior, and broker resources.

A better planning question is:

Text
required parallel workers + expected throughput growth + ordering constraints + operational headroom = partition-count decision

If traffic later exceeds the design, first identify whether the limit is partition parallelism, broker capacity, consumer processing time, or key skew. Those require different fixes.

Hot partitions are usually a distribution problem

A hot partition occurs when one partition receives substantially more work than its peers.

The cause is often the key distribution rather than the raw number of partitions.

Consider a SaaS event topic keyed by tenant ID. If one tenant produces 60% of all events and tenant-wide ordering is required, that tenant's records must remain together. Increasing the topic from 12 partitions to 24 does not split that one tenant's ordered stream across two partitions automatically.

The design options are then application decisions:

  • keep strict tenant-wide ordering and provision for the hot key;
  • narrow the ordering domain, such as tenant + resource, if the business logic permits it;
  • separate unusually large workloads into a dedicated topic;
  • redesign downstream processing so one entity does not serialize unrelated work.

This is why “add partitions” should not be the default answer to uneven throughput.

Use this diagnosis before changing the topic:

SymptomLikely first investigation
One partition much busier than peerskey distribution and hot entities
All partitions busyaggregate topic capacity and broker resources
Consumers lag while brokers are comfortableconsumer processing and concurrency
More consumers do not increase throughputpartition count or a single hot partition
Storage pressure is concentratedpartition placement, key distribution, retention, and broker capacity

Detailed lag, rebalance, and recovery behavior belongs in the upcoming Kafka consumer-groups guide. The partition page should stop at identifying whether partition design is constraining the consumer layer.

Replication factor changes fault tolerance, not application parallelism

Partition count and replication factor solve different problems.

A topic with 12 partitions and a replication factor of 3 still has 12 logical partitions for application ordering and consumer parallelism. The additional replicas provide redundant copies of those partitions; they do not turn the topic into 36 independent application partitions.

The Apache Kafka 4.3 operations guide describes replication factor separately from partition count because one controls replica copies while the other controls topic sharding.

SettingPrimary purposeDoes it increase consumer-group parallelism?
Partition countordering domains and parallel workYes, when consumers can use the additional partitions
Replication factorredundant copies and broker-failure toleranceNo
Broker countphysical capacity and replica placementNot by itself
Consumer countprocessing workersOnly up to available assigned partitions

Kafka documentation commonly illustrates production replication with multiple copies; the exact factor should follow the failure tolerance, cluster size, durability expectations, and placement model of the workload.

A higher replication factor also consumes more storage and replication traffic. It should therefore be chosen as a reliability decision, not as a performance shortcut.

For the relationship between replication, acknowledgements, retention, and data-loss tolerance, see Kafka Retention: Durability, Replication & Data-Loss Trade-Offs.

Increasing partition count later can change routing assumptions

Partition count is not always permanent, but changing it later has consequences.

Kafka supports increasing the partition count of a topic. However, the current operations documentation warns that key-based partition assignment can change when the number of partitions changes. A producer that maps a key across N partitions may map that same key differently after the topic has N + x partitions.

That means teams should not assume that adding partitions preserves the historical location of every key.

Two effects matter:

  1. New records may route differently. A key that previously mapped to partition 2 may map to another partition after the count changes, depending on the producer's partitioning strategy.
  2. Existing records are not automatically reshuffled into the new partition layout. Historical data remains where it was written while new traffic can use the expanded set.

For applications that depend on uninterrupted per-key ordering across the change, this requires planning. The safe approach is to treat partition expansion as an architecture change with producer, consumer, and ordering implications rather than a routine capacity toggle.

Kafka's current operations guide also states that partition count cannot be reduced. That asymmetry is another reason not to create a very large count without a workload reason.

At Raff, the practical rule is to leave reasonable growth headroom but avoid speculative over-partitioning. A partition increase should have a documented reason such as consumer concurrency, sustained throughput, or a deliberate change in workload distribution.

The decision framework separates key, partition, replica, and broker choices

Partition planning becomes clearer when four decisions are kept separate.

RequirementPrimary design leverQuestion to answer
Preserve event order for an entityPartition keyWhat is the smallest required ordering domain?
Increase independent processingPartition countHow many parallel units does the workload need?
Avoid one overloaded shardKey distributionAre traffic-heavy keys skewing one partition?
Tolerate broker failureReplication factor and placementHow many copies and failure domains are required?
Add physical capacityBroker capacity/countIs the cluster resource-bound rather than partition-bound?
Scale consumersConsumer count + partitionsAre enough partitions available for useful workers?
Expand laterPartition-count change planWill key routing or ordering assumptions change?

Use this sequence before changing infrastructure:

Text
1. Define the ordering domain. 2. Choose a stable, well-distributed key where possible. 3. Estimate required consumer concurrency and throughput headroom. 4. Choose partition count from those requirements. 5. Choose replication from failure tolerance, not parallelism. 6. Verify broker capacity and replica placement. 7. Revisit the design when measurements show a specific bottleneck.

The same framework helps diagnose scaling actions:

Observed constraintMost likely action
One key dominates one partitionrevisit key or topic boundary
All partitions saturated but brokers have roomevaluate more partitions
Brokers are resource-bound across many partitionsadd/resize broker capacity or use managed scaling
Consumer count exceeds partitionsmore consumers alone will not help
Failure tolerance is insufficientreview replication and placement
Lag grows with healthy brokersinspect consumer processing before changing partition count

This separation prevents a common architecture mistake: using broker capacity, partition count, and replication factor as interchangeable scaling controls.

Managed Kafka changes execution ownership, not partition design

A managed Kafka service can take ownership of more broker lifecycle and infrastructure work, but the application team still owns the partition model.

Your team still decides:

  • topic boundaries;
  • partition keys;
  • required ordering;
  • partition count and growth expectations;
  • consumer concurrency;
  • acceptable skew;
  • retention requirements;
  • application behavior when routing or topology changes.

The provider can execute more of the underlying broker operations, capacity work, maintenance, and supported service changes. That distinction is the same operating-model boundary described in Managed Kafka vs Self-Hosted Kafka.

Raff maintains a dedicated managed Kafka product path. Product availability, supported versions, plan sizes, and pricing can change independently of this architecture guide, so use the live product page for current service details.

For design work, the durable sequence remains:

key correctness -> partition distribution -> consumer parallelism -> replication requirements -> broker capacity.

Conclusion

Kafka partitions should be designed from ordering and workload requirements, not from a generic partition-count formula.

Choose the key first because it defines which events must remain together. Choose the partition count from required parallelism, expected traffic, and growth. Treat hot partitions as a distribution problem before assuming more partitions will help. Then choose replication independently for broker-failure tolerance.

Partition expansion is possible, but it can change key-routing assumptions and Kafka does not support reducing the count afterward. That makes early headroom useful, but speculative over-partitioning unnecessary.

Return to Kafka Architecture for Small Teams for the broader event-streaming model, then continue with Kafka Consumer Groups: Lag, Rebalances & Recovery for lag, rebalances, offsets, and recovery behavior.

Review Raff Managed Kafka's connectivity and broker-operations scope after defining your topic, key, partition, and replication requirements.

Was this article helpful?
Serdar Tekin
Serdar Tekin
Co-Founder & CTO

Co-Founder & CTO at Raff, focused on cloud infrastructure, systems architecture, security, reliability, and production operations.

Put it into practice

Spin up a Raff server, follow the steps above on real infrastructure, and you are live. Linux or Windows, backed by a 14-day money-back guarantee.

Frequently asked questions

What is a Kafka partition?
A Kafka partition is an ordered log segment inside a topic. Partitions let Kafka distribute storage and processing while preserving record order within each partition.
How many Kafka partitions should a topic have?
Choose partition count from ordering requirements, required consumer concurrency, sustained workload, and growth headroom. There is no universal correct number for every topic.
How does a Kafka partition key work?
A partition key identifies the ordering domain for related records. Kafka routes records with the same key to the same partition so that partition can preserve their write order.
Can Kafka partitions be increased later?
Yes. Kafka supports increasing a topic's partition count, but key-based routing can change after the increase and existing records are not automatically redistributed.
Can Kafka partitions be decreased?
No. Current Apache Kafka operations documentation states that a topic's partition count cannot be reduced, so avoid speculative over-partitioning without a workload reason.
Does a higher Kafka replication factor increase consumer parallelism?
No. Replication creates additional copies of each partition for fault tolerance. Consumer parallelism is driven by logical partition count, not the number of replicas.
Should I add partitions or add brokers to scale Kafka?
Add partitions when logical parallelism is the constraint. Add broker capacity when physical resources are constrained. If one partition is hot, investigate key skew before doing either.