Kappa architecture is a data processing design in which every result is computed by a single stream processing pipeline that reads from an immutable, replayable event log. In streaming data systems it replaces the separate batch and speed layers of Lambda architecture with one code path, so historical recomputation becomes a matter of replaying the log rather than running a different batch job.
The pattern was proposed in 2014 by Jay Kreps, one of the creators of Kafka, as a response to the operational cost of maintaining two codebases. It assumes that the log retains enough history, that the stream processor can handle reprocessing at high speed, and that results can be rebuilt into a fresh output table and then swapped in.
How Kappa architecture processes and reprocesses data
Kappa architecture works by treating the event log as the system of record and every downstream table as a derived, disposable view. Producers append events to a durable, partitioned log such as Kafka, Apache Pulsar or Redpanda, and one or more stream processing jobs consume those events to maintain outputs in databases, search indexes or analytical stores.
When business logic changes or a bug is found, engineers do not patch the existing output. They deploy a second instance of the job with the new code, point it at the beginning of the retained log, let it catch up to the present, and then switch consumers to the new output table. The old job and its table are retired afterward. This replay-and-swap procedure is the defining mechanism of the pattern.
The following table lists the core components and the role each one plays.
| Component | Role | Typical technology |
|---|---|---|
| Event log | Durable, ordered, replayable history of all events | Kafka, Apache Pulsar, Redpanda |
| Stream processor | Applies transformations, joins and aggregations | Apache Flink, Kafka Streams, Spark Structured Streaming |
| State store | Holds keyed intermediate state for aggregations | RocksDB, embedded key-value stores |
| Serving layer | Exposes derived views to applications and analysts | Relational database, OLAP store, search index |
| Schema registry | Keeps event formats compatible across code versions | Avro, Protobuf or JSON Schema registry |
Preconditions that make the pattern viable
Kappa architecture is viable only when the log can serve as a complete history. That requires long or infinite retention, often achieved with log compaction for keyed entities or tiered storage that offloads older segments to object storage while keeping them readable through the same consumer API.
The stream processor must also deliver reprocessing throughput far above the live ingest rate. A job that consumes at only twice the production rate needs a week to replay a week of history while live traffic keeps arriving, which is rarely acceptable. In practice, teams provision parallelism by partition count and temporarily scale workers during a replay.
Correctness during replay depends on event-time semantics. Because historical events are read much faster than they were produced, windows must be computed from timestamps embedded in the events, with watermarks bounding late data, rather than from processing time. Exactly-once semantics or idempotent sinks prevent duplicate results when jobs restart mid-replay.
| Requirement | Why it matters | Common way to meet it |
|---|---|---|
| Retained history | Replay needs every relevant event | Compaction or tiered storage |
| High replay throughput | Recomputation must finish in hours, not weeks | More partitions and temporary scaling |
| Event-time processing | Replayed windows must match live windows | Event timestamps with watermarks |
| Deterministic logic | Two runs must produce the same result | Avoid wall-clock calls and external lookups |
| Idempotent or transactional sinks | Restarts must not double-count | Upserts by key or two-phase commit |
Kappa architecture compared with Lambda architecture
The essential difference is that Lambda architecture runs two pipelines and merges their outputs, while Kappa architecture runs one pipeline and recomputes by replay. Lambda pairs an accurate but slow batch layer with a fast but approximate speed layer; Kappa argues that a sufficiently capable stream processor can be both accurate and fast.
Neither design is universally superior. Lambda tolerates weaker streaming guarantees because the batch layer eventually corrects errors, whereas Kappa demands mature exactly-once processing and careful state management. Micro-batch processing engines can serve either design, since the distinction concerns pipeline topology rather than execution granularity.
| Aspect | Kappa architecture | Lambda architecture |
|---|---|---|
| Number of code paths | One streaming codebase | Separate batch and speed codebases |
| Source of truth | Replayable event log | Master dataset in batch storage |
| Recomputation | Replay the log into a new output | Rerun the batch job |
| Consistency risk | Low, same logic everywhere | Divergence between the two layers |
| Operational load | One system to run and test | Two systems and a merge step |
| Ad hoc historical queries | Weaker without a separate lake | Strong through batch storage |
When to choose a Kappa design
A Kappa design is the right choice when most consumers need fresh, continuously updated results and the transformations are expressible as stream operations. It fits event-driven products, operational analytics and real-time feature pipelines for machine learning, where a single definition of each metric reduces disputes about which number is correct.
It is a weaker fit when workloads are dominated by large exploratory scans or complex joins across years of data. Many organizations therefore combine a Kappa pipeline for operational outputs with a lakehouse that receives the same events for analytical queries, which keeps the single-code-path benefit where it matters most.
| Situation | Recommended approach | Reason |
|---|---|---|
| Low-latency dashboards and alerts | Kappa | One pipeline keeps metrics consistent and fresh |
| Frequent logic changes | Kappa with replay | New versions are tested against full history |
| Petabyte-scale ad hoc analysis | Batch or lakehouse alongside | Scans are cheaper on columnar storage |
| Short log retention only | Lambda or hybrid | Replay cannot rebuild old results |
| Strict regulatory recomputation | Kappa with archived log | Deterministic replay provides an audit trail |
Limitations and common mistakes
The most frequent failure is underestimating replay cost. Reprocessing months of events can saturate brokers, evict page caches and slow live consumers, so replays should run against separate consumer groups with throttling and, where possible, from tiered storage rather than hot disks.
- Schema evolution breaks replay when old events cannot be decoded by new code; a schema registry with backward compatibility rules prevents this.
- Non-deterministic logic, such as calls to external services during processing, yields different results on each replay.
- Large keyed state makes job restarts slow; checkpoint sizes of hundreds of gigabytes are common and require planning.
- Deleting data for privacy conflicts with an immutable log; compaction with tombstones or crypto-shredding is needed to honor erasure requests.
Stripped to the essentials
Imagine a shop that writes every sale into one notebook and never erases anything. Any report the shop needs, such as daily totals or best-selling items, is worked out by reading that notebook. If the shop discovers that a report was calculated wrongly, it simply reads the notebook again from the first page with the corrected method and replaces the old report.
That is the whole idea of Kappa architecture. One recorded history and one way of processing it replace two separate systems that might disagree. The cost is that the notebook must be kept for a long time and reread quickly when needed.
Where it is applied
A mid-sized ride-hailing company streams trip, pricing and driver events into a Kafka cluster with 64 partitions and tiered storage that keeps 18 months of history. A single Apache Flink job computes per-city earnings, surge statistics and driver utilization, writing results into an analytical database that powers both operations dashboards and weekly finance reports.
When the finance team changes how cancellation fees are attributed, engineers deploy a second Flink job with the new rule, replay the full 18 months at roughly 40 times the live rate, and complete the backfill in about 11 hours. After comparing totals, they switch the dashboards to the new table and stop the old job. The outcome is one consistent set of numbers for operations and finance, without maintaining a separate batch codebase.