29. The Kappa architecture: one path, replayed
Kappa keeps one streaming path. When the logic changes, the new version of the job reads the retained log again from the start into a new view, and readers switch to it once it has caught up. It removes Lambda's second code path, and depends on three things: a log that still holds the events, schemas the new code can read, and capacity to replay faster than new events arrive.
The clip shows one log and one job. Job v1 has the same currency bug as Lambda's speed layer. The fix is deployed as job v2, which reads the log again from offset 0 into a new view and gets the right total; when it has caught up, readers switch and v1 stops. Then what the replay depended on: retention, so the log still holds the events; a compatible schema, so v2 can read v1's events; and capacity, so the replay outpaces the live feed.
The intuition: re-read the diary, do not keep two diaries
Harbour Mutual's fraud team changes how it computes its features every quarter, and each time every claim's score must be recomputed the new way. With Lambda they would change the batch job and the stream job and hope the two still agree. With Kappa there is only the stream job, and a diary: the log of every claim event, kept long enough.
To change the logic, they write the new job and let it read the diary from the first page into a new notebook, while the old job keeps the current notebook up to date. When the new notebook has caught up to today, everyone switches to it. It only works if the diary still has the pages, if the new job can read the old handwriting, and if it reads faster than new pages are written.
How it works, step by step
The log is the source of truth: every event, in order, kept for a retention period (or for ever, in a compacted or archived log). The views are derived from it and can always be derived again.
A logic change is deployed as a new job version with its own checkpoint, started from offset 0 (the earliest event retained), writing a new view. The old job keeps serving readers meanwhile. When the new job's lag reaches zero, readers switch to the new view and the old job and view are removed.
The replay works only if the new code can read every old event: the event's schema must have changed compatibly. Adding an optional field with a default is backward compatible: new code reads old events, which lack the field, by taking the default. Renaming or adding a required field is not: every old event fails to read.
The replay must also finish. While it reads the backlog, new events keep arriving, so it catches up at the replay rate less the live rate: catch-up time = backlog ÷ (replay rate − live rate). If the replay is not faster than the live feed, it never catches up.
| Dependency | The check | Without it |
|---|---|---|
| Retention | The log still holds every event the new view needs | The view can be rebuilt only for the days the log still keeps |
| Compatible schemas | The new code can read the oldest event in the log | The replay fails on the first old event |
| Capacity | The replay reads faster than new events arrive | The new job never catches up, and readers never switch |
By hand
Job v1 forgot the currency rule. Deploy v2 and replay the ten events.
| Event | Claim | Policy | Reported | Reached the log | Amount | Note |
|---|---|---|---|---|---|---|
| E01 | C-201 | P-1001 | 09:01:40 | 09:02:10 | €1,200 | – |
| E02 | C-202 | P-1002 | 09:04 | 09:04:50 | €2,400 | – |
| E03 | C-203 | P-1003 | 09:06:30 | 09:07:45 | £800 | health details |
| E04 | C-204 | P-9999 | 09:09 | 09:09:40 | €650 | – |
| E06 | C-206 | P-1006 | 09:14:20 | 09:15:05 | €950 | – |
| E07 | C-207 | P-1007 | 09:14:50 | 09:15:12 | €4,200 | – |
| E08 | C-208 | P-1008 | 09:15 | 09:15:20 | €700 | – |
| E09 | C-209 | P-1009 | 09:18:30 | 09:19:10 | €1,500 | – |
| E05 | C-205 | P-1005 | 09:12:10 | 09:21:30 | €3,100 | – |
| E10 | C-210 | P-1010 | 09:24 | 09:25:40 | €2,600 | – |
- What does v1's view show?
Predict the result, then check it
€17,450, with the travel claim counted in pounds. - v2 reads the log from offset 0. How many events does it read, and what is its view?
Predict the result, then check it
All 10; its view is €17,570. - Instead, v2 renames the required field amount to amount_eur. How many old events can it read?
Predict the result, then check it
0 of 10: the replay fails. - The replay reads 5 events a minute while 1 new event a minute arrives. How long to catch up with a backlog of 10?
Predict the result, then check it
10 ÷ (5 − 1) = 2.5 minutes. - At Harbour Mutual's size, 30 days of the log (3,600,000 events) read at 2,000 a second while 1.4 a second arrive: how long?
Predict the result, then check it
About 30.0 minutes.
What you found: One job, one code path: the fix reached every past claim by a replay of 10 events, because the log kept them, v2 could read them and the replay outpaced the feed.
- Run the new version beside the old, with its own checkpoint and view
- Without it: Readers see a half-rebuilt view, or the old view is lost before the new one is ready.
- Switch only when the new job's lag is zero
- Without it: Readers move to a view that is still hours behind.
- Evolve schemas compatibly
- Without it: The new job cannot read the history it was meant to replay.
- Keep the log as long as the history you must rebuild
- Without it: A fix can only reach as far back as the log remembers.
- Kappa means there is never any batch.
- In fact: A replay is a batch-sized read through the stream job; Kappa removes the second code path, not the large reads.
- Any log can be replayed.
- In fact: Only as far as it retains and only if the code can read it: with a renamed required field, 0 of 10 events are readable.
- A replay is quick because the job is fast.
- In fact: It races the live feed: at Harbour Mutual's size it takes about 30.0 minutes, and longer the more days are kept.
When it fits, and when it does not
- Fits: logic that changes and must be applied to history, one team that wants one code path, and a log that can keep enough history (or archive it to the lake).
- Does not fit: history longer than any log will hold and no archive, incompatible schemas nobody will migrate, or a book of record that must be produced by a separate batch.
Design notes
Register event schemas and check every new version for compatibility before it ships. Archive the log to the lake (Event Hubs Capture) so the replay can reach further back than the broker's retention. Measure the replay rate in advance, so the catch-up time is a number in the change plan, not a surprise.
Why it matters
Kappa turns "recompute everything" from a project into a deployment. That is worth a great deal to a team that changes its logic often, and it is only true if retention, schemas and capacity were designed for it.
On Azure (checked against Microsoft Learn on 24 October 2026)
- Azure Event Hubs keeps events up to 7 days on Standard and 90 on Premium and Dedicated; Event Hubs Capture writes them to the lake for longer replays.
- The Event Hubs schema registry (Standard and above) checks Avro schema changes for backward or forward compatibility at the schema group level.
- A replay in Azure Databricks is the corrected job started with a new checkpoint from the earliest offset, or from the captured files.
Where it goes wrong
- A log that forgets. Seven days kept, a fix that needs thirty.
- A breaking schema change. The new job cannot read the old events.
- Switching too early. Readers move to a view still catching up.
- A replay that cannot win. It reads no faster than the live feed and never catches up.
- Explain how Kappa applies a logic change by replaying the log.
- Say which schema changes keep a replay possible, and why.
- Compute a replay's catch-up time against the live feed.
- Decide whether retention is long enough for the history you must rebuild.
Check yourself
Choose an answer to each question, then press Check.
Sources
The works this page draws on, summarised in its own words rather than quoted. Read them for the full argument.
- J. Kreps, "Questioning the Lambda Architecture" (2014)The Kappa architecture: one job over a replayable log, and switching to a new view.
- M. Kleppmann, Designing Data-Intensive Applications (O'Reilly, 2017), chapters 4 and 11Schema evolution and compatibility, and reprocessing a log.
- Microsoft Learn: Schema Registry in Azure Event HubsBackward and forward compatibility checked at the schema group level.
Practise it
The chapters that put this theory to work on Harbour Mutual and Kestrel:
- Chapter 30: Lambda and Kappa: architectures for streaming
- Chapter 31: Pipeline patterns: choosing and combining
The tools to try it in:
- Pipeline patterns lab · Run the same claim events through eight pipeline patterns and see latency, overhead, a consumer failing, a delivery repeated and a logic change replayed.
- Stream lab · Run one claims feed as batch, Lambda and Kappa side by side, inject a late correction and replay the log.
Terms taught here: Schema compatibilityCatch-up time