00:00

Apache Kafka Topic

In Apache Kafka, a topic is a logical category or channel where data is stored and organized. Think of a Kafka topic like a news channel. Each channel focuses on one type of information, and people can choose which channel they want to watch.

Applications send data to Kafka topics, and other applications read data from those topics. Kafka itself does not change the data; it only stores and delivers it efficiently.

Key Features of a Kafka Topic

  • Named Stream of Data
    Each topic has a unique name that represents the type of data it holds, such as order-events or user-logs.
  • Append-Only
    Data is always added at the end of a topic. Existing messages are never modified or deleted by producers.
  • Partitioned for Performance
    A topic is divided into multiple partitions. This allows Kafka to handle large volumes of data and support parallel processing.
  • Ordered Within a Partition
    Messages inside a single partition are stored in the exact order they arrive.
  • Durable and Persistent
    Messages are stored on disk and remain available even if Kafka restarts.
  • Supports Multiple Consumers
    Many consumers can read from the same topic independently without affecting each other.
  • Configurable Retention
    Topics can be configured to keep data for a specific time (for example, 7 days) or until a size limit is reached.

Simple Example of a Kafka Topic

Imagine an online shopping application.

When a customer places an order, the application sends an event to a Kafka topic named:

order-created

Different services can consume data from this topic:

  • Inventory Service – updates product stock
  • Payment Service – processes payment
  • Notification Service – sends email or SMS to the customer

All these services read the same message from the order-created topic, but each service performs its own task. This makes the system flexible and scalable.

Why Kafka Topics Are Important

Kafka topics help separate data producers from data consumers. Producers do not need to know who will read the data, and consumers can join or leave at any time. This design makes Kafka ideal for building real-time, event-driven systems.

Summary

A Kafka topic is a core concept in Apache Kafka that acts as a container for related messages. It allows applications to publish and consume data in a reliable, scalable, and high-performance way. With features like partitioning, durability, and support for multiple consumers, Kafka topics form the backbone of modern event-driven architectures.

In simple terms: Kafka topics are like organized data streams that help applications talk to each other efficiently.