SDE & MLE Prep

Batch vs Stream Processing

Batch (MapReduce, Spark, warehouse SQL)Stream (Flink, Kafka Streams, Spark Structured Streaming)
Inputbounded data at rest (S3, HDFS, tables)unbounded event streams (Kafka)
Latencyminutes to hoursmilliseconds to seconds
Strengthseasy reprocessing, big joins, cheapfresh results, alerting, real-time features

Streaming concepts interviewers probe:

  • Windows: tumbling (fixed, non-overlapping), hopping/sliding (overlapping), session (closed after a gap of inactivity).
  • Event time vs processing time: aggregate by when the event happened; watermarks estimate "all events up to time T have arrived"; allowed lateness updates results for stragglers; very late events go to a side output.
  • State & exactly-once: operators keep state (counts, joins) that is periodically checkpointed; after a failure, restore the checkpoint and replay Kafka from the saved offsets; idempotent or transactional sinks complete end-to-end exactly-once.
  • Lambda = batch layer (correct) + speed layer (fresh), merged at query time — two codebases. Kappa = streaming only; reprocess history by replaying the log.