Batch vs Streaming Questions with Answers

18 practice questions on Batch vs Streaming (Data Engineering) with answers and step-by-step solutions. Try 10 samples below, then practise all 18 free in the AptiNest app.

Sample questions

Question 1Easy

Which workload is a natural fit for batch processing?

  1. Alerting on a server's CPU spike within seconds
  2. Showing live driver locations on a ride-hailing map
  3. A nightly job that builds yesterday's sales report
  4. Blocking a fraudulent card swipe while the customer waits

Answer: C. A nightly job that builds yesterday's sales report

Explanation

Batch jobs process bounded chunks of data on a schedule; the others need low-latency streaming.

Step-by-step solution

  1. Batch processing handles scheduled, non-urgent tasks.
  2. Building sales reports takes time and runs at night.
  3. It processes large data sets in batches.
  4. Other options require real-time responses.
  5. Final answer: A nightly job that builds yesterday's sales report.

Why the other options are wrong

  • A. Alerting within seconds is real-time streaming work, not a scheduled batch job over stored data.
  • B. Live driver locations need continuous updates on a map, which is streaming, not a batch job.
  • D. Blocking a card swipe while the customer waits needs an immediate answer, so it is real-time, not batch.

Tip: Look for tasks that run on a schedule and don’t need instant results.

Question 2Easy

Processing an event "exactly once" in a stream processor means:

  1. Its effect on results appears once, even after failures and retries
  2. The event is physically delivered over the network exactly once, never resent
  3. The event can never be replayed from the log again
  4. The event is deleted from the source as soon as it is read

Answer: A. Its effect on results appears once, even after failures and retries

Explanation

Delivery may repeat internally; exactly-once refers to the effect on state and output, achieved with checkpoints and idempotent or transactional sinks.

Step-by-step solution

  1. Exactly once ensures results are not changed by retries or failures.
  2. It guarantees the final outcome is as if the event was processed once.
  3. Checkpoints and idempotent operations prevent duplicate effects.
  4. This matches option A exactly.
  5. Final answer: A.

Why the other options are wrong

  • B. Exactly once is about effects on results, not physical delivery, which can still repeat over the network.
  • C. Events can still be replayed from the log; exactly once is about effects, not replay being impossible.
  • D. Deleting the source record on read is unrelated to exactly-once processing of results.

Tip: Focus on output consistency, not network reliability.

Question 3Easy

Which statement correctly describes a bounded data set?

  1. It has a known, finite size, like yesterday's log file
  2. It can only be stored in a relational database, never in files
  3. It is limited to 1,000 rows by definition
  4. It keeps growing forever as new events arrive

Answer: A. It has a known, finite size, like yesterday's log file

Explanation

Batch jobs operate on bounded data; streams are unbounded.

Step-by-step solution

  1. Bounded data has a fixed, known size.
  2. Log files from yesterday have a defined end.
  3. So it is finite and known.
  4. This matches option A.
  5. Final answer: It has a known, finite size, like yesterday's log file.

Why the other options are wrong

  • B. Bounded data can be stored in files as well as databases; a relational database is not required.
  • C. Bounded data has no fixed row limit like 1,000; its size is finite but not set at 1,000 rows.
  • D. Data that keeps growing forever is unbounded, which is the opposite of bounded data.

Tip: Remember: Bounded data is fixed; unbounded data keeps growing.

Question 4Easy

How many tumbling 5-minute windows cover one hour of events?

  1. 11
  2. 12
  3. 5
  4. 60

Answer: B. 12

Explanation

Tumbling windows do not overlap: 60 / 5 = 12.

Step-by-step solution

  1. One hour has 60 minutes.
  2. Each window is 5 minutes long.
  3. 60 divided by 5 equals 12.
  4. Tumbling windows do not overlap.
  5. So, 12 windows cover one hour.

Why the other options are wrong

  • A. Eleven is off by one; 60 divided by 5 is exactly 12 non-overlapping five-minute windows.
  • C. Five windows would cover only 25 minutes; a 5-minute window needs 12 of them to cover 60 minutes.
  • D. Sixty counts minutes, not windows; each 5-minute window covers five minutes, so there are 12 windows.

Tip: Divide total time by window size for tumbling windows.

Question 5Medium

Event time differs from processing time because event time is:

  1. When the stream processor finally read the event from the topic
  2. When the dashboard query was last refreshed
  3. When the stream processor read the event
  4. When the event actually happened at the source

Answer: D. When the event actually happened at the source

Explanation

Network delays and outages make processing time lag event time, and events can arrive out of order.

Step-by-step solution

  1. Event time is the actual time when an event occurred at its source.
  2. Processing time is when the system handles the event, which may be later.
  3. Event time is not based on when the event was read or processed.
  4. It reflects the real-world occurrence of the event.
  5. The correct answer is When the event actually happened at the source.

Why the other options are wrong

  • A. When the processor read the event is processing time, which can be later than when it happened.
  • B. The dashboard refresh time is unrelated to when the event happened at its source.
  • C. The time the stream processor read the event is processing time, not event time.

Tip: Remember: Event time is about real-world timing, not system timing.

Question 6Medium

Micro-batch stream processing works by:

  1. Loading the full history again for each new event and recomputing all results
  2. Running small batch jobs on events collected every short interval
  3. Waiting until the end of the day to process events
  4. Processing each event on a separate physical server

Answer: B. Running small batch jobs on events collected every short interval

Explanation

Micro-batching trades a little latency (often around a second or more) for batch-style efficiency and simplicity.

Step-by-step solution

  1. Micro-batch processing collects events over a short interval.
  2. It then runs a small batch job on each group of collected events.
  3. This gives batch-style efficiency with a little latency, so the answer is option B.

Why the other options are wrong

  • A. It does not reload the full history for each new event.
  • C. Micro-batches run every short interval, not once at the end of the day.
  • D. It does not use a separate server for each event.

Tip: Micro-batch means streaming done as many tiny batch jobs run every few seconds.

Question 7Medium

Why do stateful stream processors need checkpoints?

  1. To restore state and positions after a failure without losing or redoing work incorrectly
  2. To convert the stream into a nightly batch file
  3. To compress the stream so that it uses less network bandwidth between operators and sinks
  4. To sort all events by key before any processing begins

Answer: A. To restore state and positions after a failure without losing or redoing work incorrectly

Explanation

Checkpoints snapshot operator state together with source offsets, which is the basis for exactly-once results.

Step-by-step solution

  1. Checkpoints save operator state and source positions.
  2. They allow recovery after failure without redoing work.
  3. This ensures no data loss or incorrect processing.
  4. Restoring from checkpoints maintains correct results.
  5. Final answer: To restore state and positions after a failure without losing or redoing work incorrectly.

Why the other options are wrong

  • B. Checkpoints do not turn a stream into a nightly batch file; they save state so processing can recover.
  • C. Compressing network traffic is not the purpose of checkpoints; they save state and source positions.
  • D. Sorting events by key is not why checkpoints exist; they record state for recovery after a failure.

Tip: Checkpoints ensure exactly-once processing by saving state and positions for recovery.

Question 8Medium

A session window groups events:

  1. Into fixed, non-overlapping blocks of equal length chosen in advance
  2. By the order in which servers received them
  3. Into windows that slide forward every second
  4. Per key until a gap of inactivity longer than a set timeout

Answer: D. Per key until a gap of inactivity longer than a set timeout

Explanation

Session windows have variable length and close after a period with no events for that key, like a user's browsing session.

Step-by-step solution

  1. Session windows close when there is no activity for a set time on a key.
  2. They are not fixed or based on event order.
  3. Windows adjust based on inactivity gaps per key.
  4. This matches the description of option D.
  5. Final answer: Per key until a gap of inactivity longer than a set timeout.

Why the other options are wrong

  • A. Fixed non-overlapping blocks describe tumbling windows, not session windows, which depend on activity gaps.
  • B. Session windows are not grouped by server arrival order; they group by key and inactivity gaps.
  • C. Windows that slide every second describe sliding windows, and session windows have no fixed slide.

Tip: Remember session windows close based on inactivity per key, not fixed intervals.

Question 9Hard

A streaming job sets a watermark of 10 minutes on event time. What does this tell the engine?

  1. Output is written to the sink once every 10 minutes
  2. Every window must stay open for exactly 10 minutes of wall-clock time first
  3. Only events newer than 10 minutes are ever read
  4. Events more than 10 minutes behind the latest seen can be treated as late

Answer: D. Events more than 10 minutes behind the latest seen can be treated as late

Explanation

The watermark lets the engine finalise windows and drop or side-output late data, bounding state size.

Step-by-step solution

  1. A watermark sets how late an event on event time may arrive.
  2. Here the watermark is 10 minutes behind the latest event time seen.
  3. Events more than 10 minutes behind can be treated as late, so they can be dropped or sent to a side output.
  4. This matches option D.

Why the other options are wrong

  • A. The watermark controls lateness, not how often output is written.
  • B. Windows are closed by event time, not by wall-clock time.
  • C. The watermark does not stop newer events being read; it marks how late data is treated.

Tip: A watermark is the allowed lateness in event time; events older than it are late.

Question 10Hard

A streaming aggregation keeps a running count per user ID with no window or expiry. Over months the job runs out of memory. Why?

  1. Counts overflow because integers are 8 bits
  2. Watermarks delete the stored state every few seconds, losing the counts
  3. Streams cannot count more than one key at a time
  4. State grows without bound as new keys keep arriving

Answer: D. State grows without bound as new keys keep arriving

Explanation

Unbounded keyed state needs windows, TTL or a watermark-based cleanup.

Step-by-step solution

  1. Streaming aggregation stores data per user ID indefinitely.
  2. New user IDs keep adding to the total state size.
  3. No window or expiry means state grows forever.
  4. State grows without bound as new keys keep arriving.
  5. Final answer: State grows without bound as new keys keep arriving.

Why the other options are wrong

  • A. Counts do not overflow because integers are 8 bits; integer size is not why the job runs out of memory.
  • B. Watermarks do not delete stored state; they track event-time progress, so this is not the cause.
  • C. Streams can count many keys at once; a streaming job keeps counts per key, so this claim is false.

Tip: Always use windows or TTL for unbounded keyed state in streams.

Practise all 18 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Data Engineering topics · All topics