Kafka
Metadata
Data Management
Information Systems
Data Processing

Kafka metadata explained (topics, partitions, brokers, offsets)

Codemia Knowledge Hub ·

Kafka metadata is the information that describes the cluster rather than the message contents: topics, partitions, brokers, offsets and consumer groups. Clients and brokers rely on it to find each other and route data. The quickest way to see a topic's metadata is kafka-topics.sh --describe.

bash
kafka-topics.sh --describe --topic my-topic --bootstrap-server localhost:9092

This shows which partitions exist for my-topic, the leader of each partition, the replica sets, and the ISR (in-sync replica) sets.

What Kafka metadata contains

  • Topics: categories or feed names that records are published to. Topic metadata includes the name, partition count, replication factor, and configuration such as retention policies.
  • Partitions: each topic is split into partitions so the log can scale horizontally across brokers. Partition metadata includes the current leader, the brokers that host replicas, and the partition size.
  • Brokers: the Kafka servers that store data and serve clients. Broker metadata includes IDs, host names, port numbers, and the topics and partitions each broker holds.
  • Offsets: every record in a partition has a sequential ID called an offset. Offset metadata includes the current log end offset and consumers' committed offsets.
  • Consumer groups: consumers can join a group to share the processing of a topic. Group metadata includes the offsets each group tracks per topic-partition.
ComponentDescriptionImportance
TopicsNames, settings, partitions, replicasOrganizing data into streams
PartitionsSplits topics for scalabilityParallel processing & fault tolerance
BrokersServers storing dataData distribution & load balancing
OffsetsPosition markers within partitionsAccurate data retrieval
Consumer GroupsManagement of consuming clientsEfficient data processing

Where Kafka stores metadata

Consumer group offsets live in the internal __consumer_offsets topic. For other metadata, such as topic configuration and partition leadership, brokers have used ZooKeeper to store and retrieve it. Since Kafka 2.8.0 there has been a move away from ZooKeeper toward a self-managed metadata quorum called KRaft (Kafka Raft metadata mode).

How clients use metadata

  1. Producers fetch topic metadata (partitions and their leaders) before sending, so each message goes straight to the right broker and partition leader.
  2. Consumers use metadata to know where to fetch from, to store and retrieve offsets, and to handle rebalances in the group.
  3. Kafka Streams and Kafka Connect use metadata heavily to manage scaling, fault tolerance, and processing state.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design