Use only a stream path, and replay the log when you need to recompute.
Kappa architecture keeps just one path for data: a stream job that reads from a log. When you need to recompute (for example to fix a bug), you do not run a separate batch job. You replay the log through a new version of the same job.
Lambda architecture needs two code bases: one for batch and one for streaming. Kappa asks a simple question: what if the stream job could also do the work of the batch job? If the log keeps all the events, then "batch" is just a stream job that starts reading from the beginning of the log instead of the end.
The log is the heart of the design. It is append-only and ordered, and consumers keep their own offset (their place in the log). A new consumer can start at offset 0 and read everything again. Because there is one code path, there is no second system to keep in line.
| Part | What it does | Examples |
|---|---|---|
| Log | Stores ordered events for a long time and lets many readers replay from any offset | Apache Kafka, Apache Pulsar, cloud streaming logs |
| Stream processor | Reads the log and computes views, keeping state | Apache Flink, Kafka Streams, Spark Structured Streaming |
| Serving store | Holds the view so users can query it fast | A database, search index or cache |
| Approach | How it works | Good and bad |
|---|---|---|
| Long retention | Keep every event in the log for a long time | Simple. Storage grows, and it can be costly. |
| Tiered storage | Move old log segments to cheap object storage but still read them as part of the log | Cheap history. Replay of old data can be slower. |
| Compacted log | Keep only the latest event for each key | Small. You lose the full history of changes. |
| Snapshot plus log | Save a view snapshot now and then, and replay only the events after it | Fast restart. You must manage snapshots. |
| User | v1 (live) | v2 | Correct |
|---|---|---|---|
| Ann | 180 | 0 | 120 |
| Ben | 145 | 0 | 95 |
| Cy | 180 | 0 | 150 |
A tiny example: the log has 24 events and the replay reads one event per tick. A real replay reads millions of events per second, but the idea is the same.
| Term | Meaning in easy words |
|---|---|
| Log | An ordered, append-only record of events that readers can replay |
| Offset | The position of an event in the log. A consumer remembers its own offset |
| Replay | Reading the log again from an earlier offset to rebuild a view |
| Retention | How long the log keeps events before deleting them |
| View | A table, index or cache that a job builds from the log |
| Reprocessing | Recomputing results by running new logic over old events |
| Deterministic | The same input always gives the same output |
| Checkpoint | A saved copy of a job's state and position, for safe restarts |
| Snapshot | A saved copy of a view at some point, to avoid replaying everything |
| Log compaction | Keeping only the newest event for each key |
| Cutover | Switching users from the old view to the new one |
| Choice | We gain | We lose |
|---|---|---|
| Long log retention | Full replay of history | More storage and cost |
| Short log retention | Cheap, small log | Cannot recompute old data without another copy |
| Replay from the start | Simple and always correct | Slow for very large logs |
| Snapshot plus replay | Fast catch-up | Extra snapshot work and storage |
| Deploy v2 next to v1 | A safe switch with a way back | Two copies of the view for a while |
| Kappa instead of Lambda | One code base | Depends on the log and the stream engine doing everything |