Inferensys

Glossary

Topic

A logical channel or category to which messages are published by producers and from which messages are consumed by subscribers in a publish-subscribe messaging system.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
PUBLISH-SUBSCRIBE MESSAGING

What is a Topic?

A topic is a fundamental logical channel in a publish-subscribe system that decouples message producers from consumers, enabling scalable, asynchronous data distribution.

A topic is a named logical channel or category to which producers publish messages and from which consumers subscribe in a publish-subscribe messaging system. It acts as a durable, append-only log, decoupling the sender from the receiver so that multiple downstream applications can independently process the same real-time data stream without direct point-to-point connections.

In systems like Apache Kafka, a topic is further divided into partitions for parallel consumption, with each record assigned a unique, sequential offset. This architecture provides high-throughput, fault-tolerant data distribution, where consumer groups manage load balancing and log compaction or retention policies control the lifecycle of the stored messages.

PUBLISH-SUBSCRIBE FUNDAMENTALS

Key Characteristics of a Topic

A topic is the fundamental addressing mechanism in publish-subscribe messaging systems, acting as a logical channel that decouples producers from consumers and enables scalable, asynchronous communication.

01

Logical Partitioning for Parallelism

A topic is divided into partitions, which are ordered, immutable sequences of records. Each partition is a unit of parallelism—multiple consumers can read from different partitions simultaneously, enabling horizontal scalability. Partitions are distributed across brokers in a cluster, and the number of partitions determines the maximum parallelism of consumption. Messages within a partition maintain strict total order, but ordering across partitions is not guaranteed.

Thousands
Partitions per topic
O(1)
Append complexity
02

Durable, Immutable Append-Only Log

A topic is implemented as an append-only commit log stored on disk. Once a message is written, it is immutable—it cannot be altered or deleted by normal operations. This design provides durability and enables features like replayability and auditability. Retention policies control how long messages persist, configurable by time (e.g., 7 days) or size (e.g., 1 TB). Log compaction is a specialized retention strategy that retains only the latest value per key, useful for maintaining current state.

Petabytes
Retained data capacity
Immutable
Write semantics
03

Publish-Subscribe Decoupling

Producers publish messages to a topic without knowledge of the consumers. Subscribers express interest by subscribing to the topic and consume messages at their own pace. This temporal decoupling means producers and consumers do not need to be online simultaneously. Spatial decoupling means they do not need to know each other's network addresses. This loose coupling is foundational to event-driven architectures and microservices communication.

1:N
Producer-to-consumer ratio
Asynchronous
Communication model
04

Consumer Groups and Offset Tracking

Consumers are organized into consumer groups for load-balanced consumption. Each partition is consumed by exactly one member within a group, enabling parallel processing. Consumers track their position using an offset—a unique sequential ID per record. Offsets are committed periodically, allowing consumers to resume from their last committed position after failure. This model supports at-least-once or exactly-once delivery semantics depending on configuration.

Per-partition
Ordering guarantee
Committed
Offset persistence
05

Schema Enforcement and Governance

Messages in a topic are typically serialized with a schema-based format like Apache Avro or Protobuf. A Schema Registry stores and validates schemas, enforcing compatibility rules (backward, forward, full) as topics evolve. This prevents data corruption and ensures that producers and consumers agree on the structure of messages. Schema evolution is critical for maintaining data contracts in long-lived streaming pipelines.

Avro/Protobuf
Common formats
Compatible
Evolution strategy
06

Replication and Fault Tolerance

Each partition is replicated across multiple brokers for high availability. One broker acts as the leader for a partition, handling all reads and writes, while followers passively replicate the data. If the leader fails, a follower is automatically elected as the new leader. The replication factor (typically 3) determines the number of copies, balancing durability against storage cost. This design ensures zero data loss in the face of hardware failures.

3x
Typical replication factor
Automatic
Leader failover
STREAMING DATA PIPELINES

Frequently Asked Questions

Clear, technical answers to common questions about publish-subscribe messaging, topic architecture, and real-time data routing in event-driven systems.

A Topic is a logical channel or category to which producers publish messages and from which consumers subscribe to receive them. In systems like Apache Kafka and Apache Pulsar, a topic is the core abstraction for organizing and durably storing streams of events. Each topic is identified by a unique name and acts as a partitioned, append-only log. Producers write records to a topic, and the messaging system ensures those records are delivered to all interested consumer groups. Topics decouple producers from consumers, allowing services to communicate asynchronously without direct dependencies. For example, an e-commerce platform might use a user-clicks topic to stream clickstream data, a checkout-events topic for purchase completions, and an inventory-updates topic for stock level changes, each consumed by different downstream services independently.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.