Stream and batch processing: recap and quiz
The module in five sentences
Section titled “The module in five sentences”- Batch and stream. A batch job reads data that has ended and an event waits for the next run, while a stream job reads a partitioned log as it grows, with at most one busy consumer per partition and a hot key stuck in one of them.
- Event time and windows. Counting by when something happened gives the answer people mean, a watermark says when a window is done, and an event behind it is late.
- Offsets and replay. A group resumes from its last commit, so some messages are read again, and exactly-once means the effect happens once inside a boundary, not that the message travels once.
- Change data capture. Reading the database’s log gives every change in order, where dual writes lose events and polling misses states and deletions, and the events can arrive twice.
- Lambda and kappa. Two paths for the same figures have to be kept in agreement, and one job that replays a retained log trades that for retention and for the capacity to replay.
How each one breaks
Section titled “How each one breaks”| Idea | What breaks | What you see | What helps |
|---|---|---|---|
| Log and consumers | One key carries most of the traffic | One partition far behind, other consumers idle | Spread or change the key, size partitions for the future |
| Event time | Events arrive late | Counts that change after the window fired, or events dropped | A watermark and an allowed lateness chosen on purpose |
| Offsets | A crash between the work and the commit | Messages processed twice | A write that is idempotent, or the offset stored with the output |
| Capture | The application writes twice, or a job polls | Lost events, missed states and deletions | Read the log, and tolerate duplicates |
| Reprocessing | The logic changes, or a bug is found | Two paths that disagree, or a log too short to replay | One job and a retention that covers how far back you recompute |
A checklist for designing a stream pipeline
Section titled “A checklist for designing a stream pipeline”Each question points back to the lesson that answers it.
- Does the answer lose value if it waits? If not, a batch is simpler. (Batch and stream)
- What is the key, and what could make one value of it hot? Count the partitions for the load you will have, not the load you have. (Batch and stream)
- Which time does each count follow? Say event time or processing time for every number on the dashboard. (Event time and windows)
- How late can an event be, and what happens to the ones later than that? Drop and count, update, or correct later. (Event time and windows)
- What happens to the work done since the last commit when a consumer dies? Decide where the commit sits and make the effect idempotent. (Offsets and replay)
- Where does the exactly-once boundary stop? List what happens outside it: emails, calls, stores without transactions. (Offsets and replay)
- How do changes leave the database? If by two writes or by polling, say what is lost. (Change data capture)
- How far back may you need to recompute, and how long would a replay take? Retention and spare capacity decide it. (Lambda and kappa)
- What do you watch? Consumer lag per partition, the connector’s lag, and how many events were late.
Check your understanding
Section titled “Check your understanding”Seven questions cover the whole module. Every option is explained, whether it is right or wrong.
Stream and batch processing: module quiz
This quiz needs JavaScript to check your answers.
Where this goes next
Section titled “Where this goes next”A stream pipeline is a chain of consumers that also produce, and every link repeats the questions of this module: what is the key, what time do we mean, what happens after a crash. The idempotency module takes the step this module keeps pointing at: how to make a repeated message harmless. The messaging module covers the queues and the outbox that feed many of these pipelines.
Your progress
Built by GhaziAlibi.
© ShardCraft. All rights reserved.