Start here
You want numbers that are fresh and also correct. This chapter compares the two famous designs that try to give you both.
What you already know
- Batch vs Streaming vs Micro-Batch: batch runs on stored data now and then. Streaming handles each event as it arrives.
- Streaming Architecture Fundamentals: Kafka keeps events in a log. The log has a retention time, and a reader can replay it from an offset.
- Stream Processing and Delivery Guarantees & Ordering: a stream job can crash and repeat work. You make the repeat harmless.
- Incremental Processing & Backfills: you can fix old results by running the job again over old data.
What you will learn
- Lambda: a batch path and a speed path, with one merged answer.
- Kappa: one streaming path. You fix old results by replaying the log.
- Streaming-first: one engine and one table for batch and stream.
- How to choose, and what each design costs.
We use the same shop and the same made-up day, 2026-01-22. We add one goal: total sales by country. Here are the orders and the customers:
| offset | order_id | customer_id | amount | event time | arrives |
|---|---|---|---|---|---|
| 0 | 110 | 2 | 30.00 | 10:02 | 10:02 |
| 1 | 111 | 5 | 9.00 | 10:04 | 10:04 |
| 2 | 112 | 3 | 20.00 | 10:06 | 10:06 |
| 3 | 113 | 1 | 12.00 | 10:04 | 10:07 |
| 4 | 114 | 4 | 7.50 | 10:08 | 10:08 |
| 5 | 150 | 2 | 18.00 | 10:09 | 10:09 |
| 6 | 151 | 1 | 8.00 | 10:10 | 10:10 |
| customer_id | country |
|---|---|
| 1 | DE |
| 2 | GB |
| 3 | US |
| 4 | NULL |
| 5 | IN |
-- Goal: total sales by country
-- Orders are joined to customers on customer_id.
-- A customer with no country is shown as 'unknown'.| country | sales |
|---|---|
| DE | 20.00 |
| GB | 48.00 |
| IN | 9.00 |
| US | 20.00 |
| unknown | 7.50 |
| total | 104.50 |
Here the topic orders has one partition, to keep the example easy. So offsets 0 to 6 follow arrival order, as in the one-log example of Streaming Architecture Fundamentals.
