liveBook · Manning

Partition

As explained in Kafka for Architects

A Kafka partition is an ordered, independently replicated subdivision of a topic that stores records and supports parallel processing.

A customer-data service may need to process profile and transaction events concurrently while keeping related updates in order. A Kafka topic groups the events; partitions divide that topic into independently processed units. Choosing the partition count is therefore both a throughput decision and an ordering decision. section 2.1 section 2.2.1

Each partition has an integer index, starting at 0, and is identified by its topic name and index. A producer directs a record to a partition, where it is appended to an immutable sequence. The record’s offset identifies its position within that partition. Order is maintained within a partition, not across the whole topic. section 2.2.1

Figure 2.5 Utilizing partitions for parallel consumption. In this setup, each thread within a service instance is allocated its own partition, with the total number of partitions determining the maximum degree of parallelization achievable.
A screenshot of a computer screen

Description automatically generated

The diagram shows how separate partition assignments allow consumers to process one topic in parallel. section 2.2.2

Partition design has three practical consequences:

  • The partition count caps the number of consumers that can process a topic in parallel within one consumer group. One consumer can handle multiple partitions; a partition belongs to only one consumer in that group at a time. section 2.2.2 section 4.1
  • A message key can direct related records to the same partition, preserving their relative order. Records in different partitions have no guaranteed order relative to one another. section 2.7
  • Partitions are replicated across brokers for redundancy. If too few replicas remain in sync during a failure, a partition can go offline; durability and availability settings must reflect the application’s tolerance for downtime or data loss. section 2.7 section 11.3.2

Customer-data processing

Suppose a service aggregates customer updates for an operational dashboard. Several consumers in one group can share its topic’s partitions, each processing an assigned portion. If processing falls behind, consumer lag indicates the backlog for a partition; adding consumers helps only up to the parallelism allowed by the partition count. section 2.1 section 4.2.1 section 4.3.1

Plan partition counts against expected consumer workload rather than assuming that more consumers will always increase throughput. Managed Kafka may still require partition configuration; serverless Kafka can instead handle partitions and capacity planning behind the scenes. section 4.3.1 section 12.2.2

How Kafka for Architects covers it

How deep it goes
Explains partition indexes, append order, offsets, consumer assignments and scaling limits; defers partition-selection strategies and partition-count optimization.
Examples
Uses a customer-data service and diagrams of topic partitioning and parallel consumer assignments.
What it assumes
Introduces topics, partitions and messages as Kafka building blocks before explaining consumer-group assignments.
What you can do after
Apply it to plan consumer parallelism, preserve related-record order and recognize when partition counts limit scaling.
How it connects
Connects partitions to topics, message keys, offsets, consumer groups, replication and consumer lag.

Also explained in

Compare how 4 books explain partition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.