Inferensys

Glossary

Apache Kafka

An open-source distributed event streaming platform used for building high-throughput, low-latency data pipelines and streaming applications that process continuous flows of records.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
DISTRIBUTED STREAMING PLATFORM

What is Apache Kafka?

Apache Kafka is an open-source distributed event streaming platform designed for high-throughput, low-latency data pipelines and streaming applications that process continuous flows of records in real time.

Apache Kafka is a distributed commit log that functions as a central nervous system for enterprise data. It ingests, stores, and transmits high volumes of event data—such as clickstreams, transactions, and sensor telemetry—with millisecond latency. Kafka decouples data producers from consumers, allowing independent scaling and fault-tolerant operation through a partitioned, replicated log structure.

In real-time customer segmentation, Kafka serves as the backbone for event stream processing (ESP) and sessionization, enabling dynamic grouping of users based on live behavior rather than batch profiles. Its exactly-once semantics and integration with stream processors like Apache Flink make it the definitive transport layer for feeding propensity scoring and next-best-action engines with fresh behavioral signals.

DISTRIBUTED STREAMING PLATFORM

Key Features of Apache Kafka

Apache Kafka combines messaging, storage, and stream processing into a single, high-throughput distributed system. These core architectural features enable it to serve as the central nervous system for real-time data in modern enterprises.

01

Distributed Commit Log

Kafka is fundamentally a distributed, partitioned, replicated commit log service. Data is written to append-only logs called topics, which are partitioned across multiple brokers. This architecture provides:

  • O(1) disk access: Sequential I/O eliminates random disk seeks, enabling extremely high throughput on commodity hardware.
  • Immutable records: Once written, records cannot be modified, ensuring a durable, ordered, and replayable sequence of events.
  • Message retention: Unlike traditional message queues, Kafka retains messages for a configurable period (e.g., 7 days) regardless of consumption, allowing new consumers to reprocess historical data.
Millions/sec
Messages per broker
Petabytes
Persistent storage capacity
02

Publisher-Subscriber Model

Kafka decouples data producers and consumers through a pub/sub pattern centered on topics. This creates a highly scalable, loosely coupled data bus:

  • Producers: Client applications that publish records to specific topics, optionally specifying a partition key for ordering guarantees.
  • Consumers: Applications that subscribe to one or more topics and pull data at their own pace, tracked by an offset pointer.
  • Consumer Groups: A set of consumers that cooperatively consume from a topic. Each partition is assigned to exactly one consumer within a group, enabling horizontal scaling of processing while maintaining strict ordering per partition.
03

Fault Tolerance via Replication

Kafka achieves high availability and durability through leader-follower replication of topic partitions:

  • Each partition has one leader broker that handles all reads and writes, and zero or more follower brokers that passively replicate the log.
  • In-Sync Replicas (ISR): The set of replicas that are fully caught up with the leader. Only ISR members are eligible for leader election.
  • Automatic failover: If a leader fails, a new leader is automatically elected from the ISR set by the Kafka controller, with zero data loss when using acks=all producer configuration.
  • This design allows Kafka clusters to survive broker failures without manual intervention, making it suitable for mission-critical data pipelines.
99.99%
Typical uptime SLA
04

Stream Processing with Kafka Streams

Kafka includes a native stream processing library that transforms data directly within the Kafka ecosystem, eliminating the need for separate processing clusters:

  • Stateful operations: Supports windowed aggregations, joins, and interactive queries over local state stores backed by RocksDB.
  • Exactly-once semantics: Guarantees that each record is processed exactly once, even in the face of failures, using idempotent producers and transactional messaging.
  • KTable abstraction: Represents a changelog stream where each record is an upsert, enabling real-time materialized views of data.
  • Embeddable library: Runs directly within any Java application, with no separate processing cluster required, simplifying deployment and operations.
05

Exactly-Once Semantics (EOS)

Kafka provides strong delivery guarantees through configurable producer and consumer semantics:

  • At-most-once: Messages may be lost but never duplicated (default, low overhead).
  • At-least-once: Messages are never lost but may be duplicated (achieved with retries and acks=all).
  • Exactly-once: Messages are delivered and processed exactly once, end-to-end, using:
    • Idempotent producers: Detect and eliminate duplicate writes using producer IDs and sequence numbers.
    • Transactional API: Atomically write to multiple partitions and commit consumer offsets, ensuring read-process-write cycles are atomic.
  • This is critical for financial systems, inventory management, and any use case where duplicate processing would corrupt state.
06

Log Compaction

Beyond time-based retention, Kafka offers log compaction to maintain the latest state for each key:

  • Instead of deleting old segments by age, compaction retains only the most recent value for each unique key within a topic.
  • Null value tombstoning: Writing a record with a null value signals deletion, and the key is eventually removed after a configurable retention period.
  • This enables Kafka to function as a distributed key-value store or a change data capture (CDC) source, where the compacted topic represents a snapshot of the current state of a database table.
  • Compaction runs asynchronously in the background on a dedicated thread pool, ensuring it does not impact read/write performance.
APACHE KAFKA

Frequently Asked Questions

Clear, technically precise answers to the most common questions about Apache Kafka's architecture, core mechanisms, and operational characteristics for real-time data streaming.

Apache Kafka is an open-source distributed event streaming platform that functions as a high-throughput, low-latency commit log for handling continuous streams of records. It works by allowing producers to publish immutable sequences of records to categorized topics, which are partitioned and replicated across a cluster of brokers. Consumers then subscribe to these topics and read records in the exact order they were written within each partition. The platform's core mechanism relies on a pull-based consumption model, where consumers request data at their own pace, and a distributed commit log architecture that writes all records to disk sequentially, enabling constant-time access and replayability. Kafka decouples data producers from consumers, allowing each to scale independently while the brokers act as a durable, fault-tolerant buffer that persists data for a configurable retention period, making it fundamentally different from traditional message queues.

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.