Inferensys

Glossary

Kappa Architecture

Kappa Architecture is a stream-processing-centric design pattern where all data is treated as an immutable stream, and both real-time and historical processing are handled by a single stream processing engine.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
STREAM PROCESSING PATTERN

What is Kappa Architecture?

Kappa Architecture is a stream-processing-centric design pattern where all data is treated as an immutable stream, and both real-time and historical processing are handled by a single stream processing engine, simplifying system design.

Kappa Architecture is a data processing design pattern that treats all data as an immutable stream, processed by a single stream processing engine. It eliminates the separate batch layer found in Lambda Architecture, simplifying system design by using the same code and framework for both real-time analytics and historical recomputation. This is achieved by storing the raw input stream in a durable, replayable log like Apache Kafka, allowing historical data to be re-processed as needed.

The architecture's core principle is reprocessing as a mechanism for correction and evolution. To update an analytical result or model, a new version of the processing application is deployed, consuming the entire historical log from the beginning. This ensures deterministic outputs and simplifies debugging. Kappa is ideal for use cases requiring a single, consistent codebase for all data processing, such as real-time feature generation for online learning systems, continuous metrics aggregation, and maintaining event-sourced application state.

ARCHITECTURAL PRIMITIVES

Core Components of Kappa Architecture

Kappa Architecture is defined by its commitment to a single, immutable data stream as the source of truth. This section details the fundamental components that make this simplified, stream-centric design pattern operational.

01

Immutable Log

The immutable log is the foundational data structure of Kappa Architecture. It is an append-only, ordered sequence of events where each record is assigned a unique, monotonically increasing offset. This serves as the single source of truth for the entire system. All data, whether a new real-time transaction or a historical record being re-ingested, is written to this log. Popular implementations include Apache Kafka and Amazon Kinesis. The log's immutability guarantees data durability and enables deterministic replay for reprocessing.

02

Stream Processing Engine

The stream processing engine is the computational core that subscribes to the immutable log, processes events, and produces derived outputs or updated states. In Kappa, a single engine handles both real-time and historical processing. For historical analysis or model retraining, the engine simply replays the log from the beginning or a specific offset. Key frameworks include Apache Flink, Apache Spark Structured Streaming, and ksqlDB. These engines provide primitives for:

  • Stateful computations (e.g., session windows, aggregates)
  • Event-time processing
  • Exactly-once semantics
03

Stream-Table Duality

Stream-table duality is the conceptual principle that a stream can be viewed as a table, and a table as a stream. This is critical for serving queryable state.

  • A stream is a changelog: a sequence of insert, update, and delete events.
  • A table is the materialized, current state resulting from applying that changelog. The processing engine continuously updates materialized views (tables) from the stream. Applications can then query these up-to-date views for low-latency access, while the stream remains the authoritative record of all changes. This eliminates the need for a separate batch-processed database.
04

Reprocessing Capability

Reprocessing is the mechanism that enables historical analysis, bug fixes, and model retraining without a separate batch system. Because all data is stored in the immutable log, the stream processing job can be stopped, its logic updated (e.g., a new feature calculation), and restarted from a previous offset. The engine then replays the entire log (or a relevant segment) through the new logic, regenerating all derived data and materialized views. This guarantees consistency between historical and real-time data paths, as they are generated by the same code.

05

Serving Layer / Materialized Views

The serving layer consists of queryable databases or caches that hold the materialized views produced by the stream processor. These are optimized for low-latency reads by downstream applications, dashboards, or model serving APIs. Examples include key-value stores (Redis, DynamoDB), OLAP databases (Apache Pinot, ClickHouse), or search indexes (Elasticsearch). The views are continuously updated as the stream processor writes new results. This layer is derived, not primary; the log remains the authoritative source for rebuilding any view.

06

Contrast with Lambda Architecture

Kappa Architecture is often contrasted with Lambda Architecture, which it aims to simplify. The key distinction is the elimination of the dedicated batch layer.

  • Lambda: Uses separate batch (e.g., Apache Hadoop) and speed (e.g., Apache Storm) layers, merging their results in a serving layer. This creates complexity from maintaining two different codebases and reconciling outputs.
  • Kappa: Uses a single stream processing layer for all computation. Historical processing is handled via log replay, ensuring logic is consistent across all time horizons. This reduces system complexity, operational overhead, and the potential for logic drift between batch and real-time pipelines.
STREAM PROCESSING PATTERNS

Kappa Architecture vs. Lambda Architecture

A technical comparison of two foundational architectural patterns for building continuous model learning systems and handling real-time data streams.

Architectural FeatureKappa ArchitectureLambda Architecture

Core Design Principle

Treats all data as an immutable stream. A single stream processing engine handles both real-time and historical computations.

Hybrid design with separate Batch and Speed layers for historical and real-time processing, respectively.

Data Processing Path

Single path: All data flows through a unified stream processing layer.

Dual path: Data is sent simultaneously to the Batch Layer (for accuracy) and the Speed Layer (for low latency).

Code Complexity & Maintenance

Lower. Requires maintaining logic for a single processing engine.

Higher. Requires developing, deploying, and synchronizing logic for two distinct processing layers.

State Management

State is managed within the stream processor (e.g., using internal state stores or an external database for large state).

State is split: Batch Layer manages the master dataset (serving layer); Speed Layer manages real-time views, which must be merged.

Historical Data Reprocessing

Reprocessing is achieved by replaying the immutable event log from the beginning or a past offset through the stream processor.

Reprocessing is handled by the Batch Layer, which recomputes the master dataset from the raw data archive.

Latency for New Data

Low latency (sub-second to seconds), as all processing is in the stream path.

Low latency for the Speed Layer, but the Batch Layer introduces high latency (hours) for the 'complete' view.

Guarantees & Fault Tolerance

Relies on stream processing engine guarantees (e.g., exactly-once semantics, checkpointing) for the single pipeline.

Relies on the robustness of the underlying batch (e.g., MapReduce, Spark) and stream processing frameworks independently.

Storage Backbone

Immutable, append-only log (e.g., Apache Kafka, Amazon Kinesis). Serves as the system of record.

Raw data archive (e.g., HDFS, S3) for the Batch Layer, plus a real-time data feed (e.g., Kafka) for the Speed Layer.

Serving Layer Complexity

Simpler. The stream processor writes directly to the serving database or API.

More complex. Requires query logic to merge the pre-computed batch views with the real-time speed layer views.

Best Suited For

Systems where logic for real-time and batch processing is similar, and a single codebase is desirable. Ideal for event-driven microservices and continuous model updates.

Systems with complex, time-intensive historical computations that are fundamentally different from real-time logic, or during migration from legacy batch systems.

APPLICATION DOMAINS

Common Use Cases for Kappa Architecture

Kappa Architecture's single-stream processing paradigm excels in scenarios demanding real-time analytics, continuous model updates, and simplified data pipeline maintenance. Its core strength is eliminating the complexity of managing separate batch and speed layers.

01

Real-Time Anomaly & Fraud Detection

Kappa Architecture is ideal for low-latency fraud detection in financial transactions or cybersecurity. Every transaction or log event is an immutable record in a stream. A stream processing job continuously analyzes this feed, applying online machine learning models (e.g., isolation forests, autoencoders) to score each event in real-time. Suspicious activities trigger immediate alerts. The same stream can be replayed to retrain detection models on historical patterns, ensuring they adapt to new fraud tactics without a separate batch pipeline.

  • Example: A payment processor ingests every card swipe as a Kafka event. A Flink job scores each transaction for fraud risk in <100ms, blocking suspicious ones instantly.
02

Continuous Model Learning & Personalization

This architecture directly supports online learning systems where models must adapt to user behavior without retraining from scratch. User interactions (clicks, views, purchases) are streamed as events. A stateful stream processor (e.g., Apache Flink, Kafka Streams) uses these events to perform incremental model updates via algorithms like online gradient descent or to update user embedding vectors. The updated model parameters are then immediately served for the next inference, creating a tight real-time feedback loop.

  • Example: A news recommendation engine updates user interest profiles and article rankings with each click, personalizing the homepage for the next refresh.
03

IoT & Telemetry Data Processing

For high-volume sensor data from connected devices, Kappa provides a unified pipeline. Telemetry from millions of devices (temperature, GPS, vibration) is published to a durable log (e.g., Apache Pulsar). Stream processing jobs perform real-time aggregations (e.g., rolling averages, threshold breaches) for dashboards and alerts. The same raw stream is simultaneously processed for historical batch-style analytics, like training predictive maintenance models, by launching new streaming jobs that consume from the beginning of the log.

  • Example: A smart grid processes power meter readings in real-time to balance load, while also replaying years of data to forecast long-term energy demand.
04

Real-Time Analytics & Monitoring Dashboards

Kappa powers live business intelligence by treating all data as a stream. Application logs, database change events, and user activity are captured in real-time. Stream processors compute aggregate metrics (counts, sums, unique users) over tumbling or sliding windows, publishing results to a low-latency database (e.g., ClickHouse, Druid) for dashboard queries. This eliminates the traditional ETL delay, providing a single source of truth for both current and historical metrics derived from the same processing logic.

  • Example: An e-commerce platform monitors live sales per second, average order value for the last hour, and regional traffic spikes on a single dashboard.
05

Event-Driven Microservices & Change Data Capture (CDC)

Kappa serves as the backbone for event-driven architectures. Database Change Data Capture logs every insert, update, and delete as an ordered event stream. Microservices subscribe to these streams to update their own caches or derived data stores, ensuring eventual consistency. The immutable log provides a complete audit trail and allows any service to be rebuilt by replaying history. This pattern is central to decoupling services and maintaining state across a distributed system.

  • Example: An order service publishes an 'OrderPlaced' event. Inventory, billing, and notification services consume it independently to update stock, create an invoice, and send a confirmation email.
06

Unified Data Lake Ingestion & Transformation

Kappa simplifies the data lake pipeline by using a single stream processing engine for all transformations. Raw data from sources is written to a durable log (the 'source of truth'). A streaming job cleans, enriches, and transforms this data in-flight, writing the results directly to the data lake (e.g., Amazon S3, ADLS) in an analytics-ready format (like Parquet). For reprocessing due to logic changes, a new version of the streaming job is deployed to consume the raw log from the beginning, ensuring consistency without a separate batch system.

  • Example: A company ingests web clickstream logs into Kafka. A single Flink job filters bots, joins with user demographics, and writes clean, partitioned data to S3 for analysis by data scientists.
KAPPA ARCHITECTURE

Frequently Asked Questions

Kappa Architecture is a stream-centric design pattern that simplifies data processing by treating all data as an immutable, real-time stream. This FAQ addresses common technical questions about its implementation, benefits, and differences from other architectures.

Kappa Architecture is a data processing design pattern where all data is treated as an immutable, append-only stream, and both real-time and historical computations are served by a single stream processing engine. It works by ingesting all data into a distributed log (like Apache Kafka), which acts as the system's central, durable source of truth. A stream processing job (e.g., in Apache Flink or Spark Streaming) reads from this log, performs computations—such as aggregations, transformations, or model inference—and writes results to serving layers or back into the log for downstream consumers. For historical reprocessing, the job is simply restarted from the beginning of the log. This eliminates the complexity of maintaining separate batch and speed layers, as seen in Lambda Architecture.

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.