How it works · 40 of 49 Advanced

Lambda vs Kappa architecture: what is the difference?

Real-time numbers and accurate history, two paths or one

Lambda vs Kappa: Lambda runs a fast, approximate path (speed layer) beside a slow, exact batch path that recomputes everything, and merges the two when asked; every rule is written twice. Kappa keeps one replayable log and one stream job; when a rule changes, it replays the log through new code into a new table and switches over.

Loading the animation…

Say it like this Lambda runs a fast, approximate path and a slow, exact batch path side by side and merges them, at the price of writing every rule twice; Kappa keeps one replayable log and one stream job, and when a rule changes it replays the log through new code.

Under the hood — for builders
Worked example: the card's shop
The till sends each order to a running tally (the speed layer) and to a box recounted at midnight (the batch layer). The network redelivers some orders, so the tally reads ₹10.2 lakh while the exact total is ₹10.0 lakh, until the recount replaces it. With Kappa, one stream job counts each order id once from the start; a new rule means replaying the kept log into a new table.
The sources, in their words
Marz, 2011 (who named Lambda): "you query the batch view and the realtime view and merge the results together"; "the realtime layer only compensates for the last few hours of data." Kreps, 2014: "maintaining code that needs to produce the same result in two complex distributed systems is exactly as painful as it seems like it would be." His fix: "retain the full log of the data you want to be able to reprocess"; "Maybe we could call this the Kappa Architecture."
Terms
Batch layer: recomputes results from all the data, slowly (Marz: "Whenever there's new data, you just recompute everything"). Speed layer: updates results as each event arrives. Serving layer: where the two are merged for a query. Log: an append-only, ordered record of every event, kept for replay. At-least-once delivery: every event arrives, some twice.
Run here: the live number runs high all day
1,000,000 orders, 2% delivered twice. A tally that doesn't check ids stays about 2% over the exact total at every hour, until the nightly recount.
Run here: how fast is a replay?
Replaying three days of that log (3.06 million events) through new code that counts each id once took 0.36–0.39 s on one core: about 8 million events a second, so 30 days in about 4 s. Real logs are bigger and reads come off disk or network, but the shape holds: Kappa needs replay to be fast and the log to be kept.
How the switch-over works (Kreps)
"start a second instance of your stream processing job" reading from the start of the log; "direct this output data to a new output table"; "When the second job has caught up, switch the application to read from the new table"; "Stop the old version of the job, and delete the old output table."
Measure it
Gap between live and exact numbers through the day · time to replay a day of the log · days of log kept vs days you may need to recompute · rules that exist in two codebases.
Watch out
Kappa needs the log kept long enough for any recompute you might need, and a stream job that can do everything the batch job did. Lambda gives a correct number by morning with a simple batch job, at the cost of two codebases. Choose by how often rules change and how long a recompute may take.
Sources
Nathan Marz, "How to beat the CAP theorem", 13 Oct 2011 · Jay Kreps, "Questioning the Lambda Architecture", O'Reilly Radar, 2 Jul 2014 · both read in session · tally and replay runs, Python, 21 Nov 2026.

What happens in the Lambda vs Kappa animation, step by step?

Lambda or Kappa: Lambda: two paths

  1. Lambda: the till sends every receipt two ways. A clerk keeps a running tally for the board right now; the receipts also go in a box an accountant recounts, in full, at midnight.
  2. The two rarely agree. The network delivers some receipts twice and only the full recount catches them: all day the live total runs about 2% high, then at midnight the board drops back.
  3. And every rule lives twice, once for the clerk and once for the accountant, and the two must stay identical. Now flip the switch above the picture to Kappa.

Lambda or Kappa: Kappa: one log

  1. Kappa: one path. The till writes every receipt onto one tape that keeps everything; one counter reads the tape and keeps the board exact as it goes.
  2. A rule changes: skip cancelled orders. Rewind the tape and start a second counter from the beginning, writing to a new board.
  3. When it has caught up, switch the shop to the new board and take the old one down. One set of code, one log, replayed.
  4. The price: keep the whole tape, and replay fast enough when you must. Next: a million fans buying tickets at 10 a.m., space-based architecture.

What everyday example explains Lambda vs Kappa?

A shop's running tally plus a nightly recount, or one till roll you can rewind. The tally is quick but can count a receipt twice; the recount is right but late; the roll gives one count you can redo.

Why should a team care about Lambda vs Kappa?

A dashboard that must be live and a report that must be right pull toward two systems; choosing Lambda or Kappa decides whether your team keeps two codebases or one long log.