Skip to content

Stream and batch processing: recap and quiz

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
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.

  1. Does the answer lose value if it waits? If not, a batch is simpler. (Batch and stream)
  2. 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)
  3. Which time does each count follow? Say event time or processing time for every number on the dashboard. (Event time and windows)
  4. 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)
  5. 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)
  6. Where does the exactly-once boundary stop? List what happens outside it: emails, calls, stores without transactions. (Offsets and replay)
  7. How do changes leave the database? If by two writes or by polling, say what is lost. (Change data capture)
  8. How far back may you need to recompute, and how long would a replay take? Retention and spare capacity decide it. (Lambda and kappa)
  9. What do you watch? Consumer lag per partition, the connector’s lag, and how many events were late.

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.

Question 1 of 7

A batch job runs once an hour, on the hour. Events arrive evenly through the hour.

On average, how long does an event wait before the job starts to look at it? Ignore the time the job itself takes.

Enter a number and choose its unit.

minutes
Question 2 of 7

A topic has 4 partitions, and a consumer group of 6 consumers reads it.

How many consumers of the group are at work?

Enter a number and choose its unit.

consumers
Question 3 of 7

One partition of a topic is far behind while the others are caught up. Most of the messages carry the same key.

What does adding consumers to the group do?

Choose one answer.

Question 4 of 7

A job counts events in one-minute windows by event time. The watermark has already passed the end of the 12:00 window, and an event stamped 12:00:20 arrives. The allowed lateness is the default of 0.

What happens to the event in Flink’s model?

Choose one answer.

Question 5 of 7

A search index must follow a table. Rows are updated several times a minute, and some are deleted.

Why is reading the database’s log a better fit than polling for rows changed since the last run?

Choose one answer.

Question 6 of 7

A group commits its offsets every 8 seconds. A consumer crashes 7 seconds after the last commit.

What does the consumer that takes over its partitions read?

Choose one answer.

Question 7 of 7

A system has a batch layer and a speed layer that compute the same figures, merged at query time.

What is the main cost that the kappa approach argues against?

Choose one answer.

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.