Inferensys

Glossary

Apache Kafka

Apache Kafka is a high-throughput, distributed streaming platform used for building real-time data pipelines and streaming applications, functioning as a fault-tolerant, publish-subscribe messaging system.
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.

Apache Kafka is a distributed publish-subscribe messaging system that functions as a fault-tolerant, horizontally scalable commit log. It allows applications to publish, subscribe to, store, and process streams of records in real-time, decoupling data producers from consumers. Originally developed at LinkedIn and open-sourced through the Apache Software Foundation, it is the de facto standard for event-driven architectures and high-volume data ingestion.

Kafka organizes data into topics, which are split into partitions distributed across a cluster of brokers for parallelism. Producers write immutable, ordered sequences of records to partition leaders, while consumer groups read in parallel with each member assigned specific partitions. Its architecture relies on ZooKeeper or the newer KRaft consensus protocol for cluster coordination, and it guarantees durability through configurable retention policies and replication, enabling both real-time stream processing and reliable historical data replay.

DISTRIBUTED STREAMING PLATFORM

Key Features of Apache Kafka

Apache Kafka combines messaging, storage, and stream processing into a single, fault-tolerant system. These core architectural features enable it to handle trillions of events per day at companies like LinkedIn, Netflix, and Uber.

01

Distributed Commit Log

At its core, Kafka is a distributed, append-only log. Producers write records to the end of a log, and consumers read sequentially using an offset pointer. This immutable, ordered structure provides:

  • Total ordering within a partition
  • Replayability of entire event streams from any point in time
  • Durability through disk persistence, not in-memory queuing

Unlike traditional message queues that discard messages after consumption, Kafka retains data based on configurable retention policies, allowing new consumers to backfill historical data without impacting producers.

1M+
Messages/sec per broker
2.5ms
Median produce latency
02

Partitioning for Parallelism

Each topic is split into multiple partitions distributed across the cluster. Partitions are the unit of parallelism:

  • A topic with 100 partitions can be consumed by up to 100 consumer instances in a consumer group
  • Producers can route messages to specific partitions by key, guaranteeing order for all events sharing that key
  • Partitions enable horizontal scaling — adding brokers increases both throughput and storage capacity linearly

This design avoids the bottleneck of a single ordered queue while preserving ordering guarantees where they matter.

200K+
Partitions per cluster
03

Consumer Group Load Balancing

Kafka distributes consumption across a consumer group by assigning each partition to exactly one consumer instance within the group. This provides:

  • Fault tolerance: If a consumer fails, its partitions are automatically reassigned to remaining members via a group coordinator
  • Scale-out consumption: Adding consumers increases processing throughput up to the partition count
  • Multi-subscriber fan-out: Different consumer groups read the same topic independently, each maintaining its own offset position

This model decouples production from consumption, allowing multiple downstream applications to process the same event stream at their own pace.

< 50ms
Rebalance latency
04

Fault Tolerance via Replication

Every partition is replicated across a configurable number of brokers (typically 3). One broker acts as the leader for reads and writes, while followers passively replicate the log. Key guarantees:

  • ISR (In-Sync Replicas): Only replicas that are fully caught up are eligible for leader election
  • Acks configuration: Producers can require acknowledgment from all in-sync replicas (acks=all) for guaranteed durability
  • Rack awareness: Replicas can be placed across availability zones to survive data center outages

A failed leader triggers an automatic election among ISRs, with zero data loss when acks=all and min.insync.replicas are properly configured.

99.99%
Availability SLA
3x
Default replication factor
05

Log Compaction for State Storage

Beyond time-based retention, Kafka supports log compaction — a retention mechanism that keeps only the latest record for each key. This transforms Kafka into a distributed key-value store:

  • Change Data Capture (CDC): Database changes streamed into Kafka maintain a compacted snapshot of current row state
  • KTable in Kafka Streams: Compacted topics back stateful stream processing operations
  • Event sourcing snapshots: Aggregate state can be rebuilt from compacted topics without replaying the entire event history

Compaction runs asynchronously in the background, periodically removing obsolete records while preserving the most recent value per key.

O(1)
Lookup per key
06

Exactly-Once Semantics

Kafka provides exactly-once semantics (EOS) across producers, brokers, and stream processors, eliminating duplicate processing even during failures. This is achieved through:

  • Idempotent producers: Each message gets a producer ID and sequence number; brokers deduplicate retries
  • Transactional writes: Producers can atomically write to multiple partitions using a two-phase commit protocol
  • Kafka Streams EOS: State stores and output topics are updated transactionally, preventing partial updates

This guarantee is critical for financial ledgers, inventory systems, and any use case where double-counting is unacceptable.

0%
Duplicate rate with EOS
APACHE KAFKA FAQ

Frequently Asked Questions

Clear, technically precise answers to the most common questions about Apache Kafka's architecture, core mechanisms, and operational characteristics for data engineers and backend developers.

Apache Kafka is a distributed, high-throughput publish-subscribe messaging system that functions as a fault-tolerant, append-only distributed commit log. It works by having producers publish ordered streams of records (messages) to categories called topics. These topics are partitioned and replicated across a cluster of brokers for parallelism and durability. Consumers subscribe to topics and read records at their own pace, tracked by an offset. This decouples data producers from consumers, enabling real-time data pipelines and streaming applications that can handle millions of messages per second with persistent storage and replayability.

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.