Contents

Kafka acts as a distributed commit log. Events (messages) are appended to topics and retained for a configurable period — consumers can replay from any offset. This differs from traditional queues where messages are deleted after consumption.

ComponentRole
BrokerA Kafka server that stores and serves messages. A cluster has multiple brokers for fault tolerance.
TopicA named log/category where messages are published. Analogous to a database table.
PartitionA topic is split into one or more ordered, immutable partitions. Parallelism unit.
ProducerApplication that publishes messages to a topic.
ConsumerApplication that reads messages from a topic.
Consumer GroupA group of consumers that together consume a topic — each partition is assigned to exactly one consumer in the group.
OffsetA unique sequential ID for each message within a partition. Consumers track their position via offsets.
ZooKeeper / KRaftCoordinates cluster metadata (broker election, topic configs). Kafka 3.x+ supports KRaft (built-in, removes ZooKeeper dependency).

A topic is a logical channel. A partition is a physical file on a broker. Partitions enable parallelism: multiple consumers in a group can read different partitions simultaneously.

Increase the number of partitions to scale throughput. However, more partitions mean more open file handles and longer leader election times. A common starting point is 1–3 partitions per broker for most topics.

Producers write messages to topics. Key settings:

Consumers read messages from topics. Key concepts:

FeatureKafkaTraditional Queue (RabbitMQ, SQS)
Message retentionConfigurable (hours/days/forever)Deleted after consumption
Replay✅ Yes — reset offset to re-read❌ No
ConsumersMultiple independent groupsCompeting consumers (one wins)
OrderingPer partitionPer queue (often)
ThroughputVery high (millions/sec)Lower
Best forEvent streaming, analytics, log pipelinesTask queues, job dispatching

Kafka Articles

  1. Kafka Producers
  2. Kafka Consumers
  3. Topics and Partitions