Skip to main content

Top 8 Stream Processing Interview Questions for Data Engineers

Stream processing continuously handles events as they arrive. The difficult part is not simply processing each message quickly: production systems must also deal with delayed and out-of-order events, duplicate delivery, state recovery, uneven traffic, and accurate results after failures.

Interview framework: Discuss event-time semantics, delivery guarantees, state and checkpoints, windowing, late-data policy, observability, and the trade-off between result completeness and result latency.

1. How does stream processing differ from batch processing?

Batch processing works on a bounded dataset, usually on a schedule. Stream processing handles an unbounded sequence of events continuously, updating results as new events arrive.

DimensionBatchStream
InputBounded files, tables, or time rangesContinuous events or records
Output timingAfter scheduled processing completesContinuously or at short intervals
StateOften scoped to a run or partitionMay persist across events and checkpoints
ChallengesLarge backfills, retries, and processing windowsLate events, state growth, backpressure, and recovery
Typical use casesDaily reporting, historical transformations, model trainingFraud detection, live monitoring, event-driven metrics

Streaming does not automatically mean every result is final or exactly-once. Delivery guarantees depend on the source, processing engine, checkpointing, and sink. Some platforms also use micro-batches internally.

Practical example: Stream payment events to flag suspicious activity quickly, then run batch reconciliation to confirm totals and repair discrepancies.

2. What is the difference between event time and processing time?

Event time is when an event actually occurred according to its timestamp. Processing time is when the streaming application processes that event. Systems may also track ingestion time, which is when the platform receives the event.

Time typeMeaningExample
Event timeWhen the business event occurredA payment occurred at 10:00
Ingestion timeWhen the platform received the eventThe broker received it at 10:04
Processing timeWhen the application handled the eventThe job processed it at 10:05

Use event time when business results should reflect when something happened—for example, hourly sales or device readings. Processing time can be useful when low latency is more important than aligning results to the original event timeline.

Example: A mobile device records an event at 10:00 but remains offline until 10:20. Event-time aggregation assigns it to the 10:00 window; processing-time aggregation assigns it to the window in which it is processed.

Watch out: Event timestamps can be wrong because of clock skew, timezone mistakes, or malformed source data. Validate timestamp quality and define the expected timezone and precision.

3. What are watermarks, and how do they affect late events?

A watermark is a system's estimate that event time has advanced to a point where events earlier than that point are unlikely to arrive, according to the configured policy. It helps a streaming engine decide when to close event-time windows and how long to retain state.

Example: Suppose a pipeline uses a 10-minute allowed-lateness policy. If the watermark advances beyond 10:00, the engine may finalize the 9:00–10:00 window under its configured semantics. An event for 9:45 arriving later may be dropped, sent to a side output, or cause an update if the engine and sink support it.

Why watermarks matter:

  • Determine when event-time windows can emit results or be considered complete.
  • Control how long state and window metadata must be retained.
  • Trade off result latency, state size, and tolerance for late data.
  • Help manage event-time progress when events arrive out of order.
event timestamp: 09:45 event arrives: 10:18 current watermark: 10:05 Possible behavior: - update the old window, if supported and still allowed - route the event to a late-data side output - drop it, if the policy says the window is closed

Exact behavior varies by engine and window configuration. Some engines support allowed lateness and repeated firing; others have different triggers and retention semantics.

Interview tip: Explain how your watermark is generated, how late events are handled, and whether downstream consumers can see revised results after a window first emits.

4. Explain tumbling, sliding, and session windows.

Windows group an unbounded stream into finite sets so the system can calculate aggregates such as count, sum, average, or maximum.

Window typeHow it worksExample use
TumblingFixed-size, non-overlapping windowsRevenue per 5-minute interval
SlidingFixed-size windows that advance by a smaller slide interval, so windows overlapRolling 15-minute request count updated every minute
SessionGroups events separated by inactivity gaps; duration depends on activityUser session or browsing activity
Conceptual timeline
Time ------------------------------------------------> Tumbling (5 min): [ 0 - 5 ][ 5 - 10 ][ 10 - 15 ] Sliding (10 min size, 2 min slide): [ 0 ------ 10 ] [ 2 ------ 12 ] [ 4 ------ 14 ] Session (5 min inactivity gap): Events: A B C D E Windows: [session 1] [session 2]

Trade-offs: Sliding windows may place one event in multiple windows, increasing computation. Session windows can require more state because sessions may extend or merge when new events arrive. All window types need a policy for late data and finalization.

5. How would you handle duplicate events in a streaming pipeline?

Duplicates can occur because producers retry, brokers redeliver messages, consumers restart, or a source emits the same business event more than once. The solution depends on whether duplicates share a stable event ID and how long deduplication must be guaranteed.

  • Use a stable event ID: Prefer a producer-generated unique ID or a documented source key.
  • Maintain deduplication state: Track processed IDs for a bounded retention period when the use case allows bounded deduplication.
  • Use idempotent sinks: Upsert by business key or use a unique constraint/transactional write where supported.
  • Choose retention deliberately: The deduplication horizon must cover realistic replay, outage, and late-arrival scenarios.
  • Preserve ordering metadata: A duplicate older event must not overwrite a newer state.
  • Monitor duplicates: Track duplicate rates by source and producer to find upstream reliability problems.
if event.id in recently_processed_ids: ignore event else: apply_event_idempotently(event) remember event.id

This pseudocode illustrates the idea, but production systems must make state updates and output writes recoverable together. If deduplication state expires, old replays may be seen again, so sink idempotency remains valuable.

Important distinction: Exactly-once processing semantics do not necessarily mean a business event can never be duplicated at the source. Correct end-to-end behavior requires compatible source, engine, state, and sink semantics.

6. What is backpressure, and how would you troubleshoot it?

Backpressure occurs when downstream processing cannot keep up with the rate of incoming data. Queues grow, consumer lag increases, and end-to-end latency rises. The root cause may be a slow sink, expensive transformation, skew, insufficient capacity, or a temporary traffic spike.

Troubleshooting sequence:

  1. Compare incoming event rate with processing and output rates.
  2. Inspect broker lag, queue depth, per-stage latency, busy/idle time, CPU, memory, garbage collection, and sink response time.
  3. Find the slowest stage rather than scaling the entire pipeline blindly.
  4. Optimize serialization, expensive transformations, network calls, and sink writes.
  5. Check key skew and partition imbalance; redistribute work where semantics allow.
  6. Increase parallelism or capacity if the stage can use it, while checking partition limits and external-system quotas.
  7. Use buffering and batching appropriately, and define overload behavior such as throttling or controlled degradation.

Example: If stream operators are healthy but the database sink writes slowly, adding more upstream workers may only increase the queue. Batch sink writes, tune connection pools, use asynchronous I/O where appropriate, or reduce unnecessary writes.

Interview tip: Track both throughput and lag. A pipeline can have high throughput but still fall behind if the input rate is higher for a sustained period.

7. How would you recover a stateful streaming application after failure?

A stateful stream processor maintains information across events, such as per-key counts, window aggregates, session state, or deduplication IDs. Recovery requires restoring both processing progress and the corresponding state consistently.

Recovery design:

  1. Use durable checkpoints or snapshots: Persist operator state and source offsets consistently according to the engine's recovery model.
  2. Restore from a consistent point: Recover state and replay input from the corresponding source position.
  3. Make outputs recoverable: Use transactional or idempotent sinks so replay does not duplicate externally visible effects.
  4. Manage checkpoint storage: Monitor checkpoint duration, size, failure rate, retention, and storage availability.
  5. Test recovery: Simulate worker loss, process restart, and checkpoint corruption in a controlled environment.
  6. Plan state evolution: Validate compatibility when changing operators, keying, serializers, or state schemas during deployments.

Example: A fraud detection pipeline stores the recent transaction count per account. After a worker failure, it restores the account counters and source offsets from a consistent checkpoint, then replays later events. A safe sink prevents duplicate alerts during replay.

Watch out: A checkpoint alone does not guarantee that external side effects are exactly once. The sink and its transaction or idempotency strategy must align with the processing engine's recovery behavior.

8. How would you maintain accurate aggregations when events arrive out of order?

Use event-time windows, watermarks, and an explicit late-event policy. The pipeline should distinguish provisional results from finalized results and define how corrections reach downstream consumers.

  • Aggregate by event time: Assign events to windows using their business timestamps rather than arrival order.
  • Set a lateness policy: Configure watermarks and allowed lateness based on observed delay distributions and business needs.
  • Support revisions: If late events change a prior aggregate, update or emit a correction to the relevant window.
  • Choose the sink contract: Decide whether downstream tables receive upserts, retractions, versioned results, or append-only correction records.
  • Handle very late events: Route them to a side output or correction workflow, and backfill affected partitions if necessary.
  • Monitor completeness: Track watermark lag, late-event rate, window revisions, and the age of the oldest unprocessed event.

Example: A 10:00–10:05 sales window initially reports $12,000. A delayed transaction later adds $300. The system can emit an updated aggregate of $12,300 or publish a correction, depending on its output contract.

event -> validate timestamp -> assign event-time window -> update window state -> emit provisional/final result -> revise result if late data is accepted -> route data beyond allowed lateness

No watermark policy can guarantee that no later event will ever arrive. “Final” typically means final under a configured operational policy, not mathematically certain for all future time.

Quick Revision Table

TopicCore takeaway
Stream vs. batchContinuous unbounded processing vs. bounded scheduled processing.
Event vs. processing timeWhen an event happened vs. when the system handled it.
WatermarksEstimate event-time progress and help govern window completion and late data.
WindowingTumbling is fixed/non-overlapping, sliding overlaps, and session groups by inactivity gaps.
Duplicate eventsUse stable IDs, deduplication state, and idempotent sinks.
BackpressureFind the slowest stage using rates, lag, and resource metrics.
State recoveryRestore state and offsets consistently, then replay safely.
Out-of-order eventsUse event-time windows, lateness policies, and correction-capable outputs.

Scenario-Based Practice Questions

Try answering these scenarios out loud before checking the suggested approach.

Scenario 1: Your watermark is not advancing. What would you investigate?

Inspect event timestamps, idle input partitions, source lag, partition skew, and the engine's watermark propagation rules. One input with very delayed timestamps can hold back progress in some systems. Verify timestamp parsing and clock quality, then configure idle-partition handling or source-specific watermark behavior where supported.

Scenario 2: Consumer lag grows even after adding workers.

Find the actual bottleneck. Check sink latency, skew, partition count, serialization cost, external quotas, and whether the added workers can receive independent partitions. Improve the slow stage, batch or optimize sink writes, and compare input rate against sustained processing throughput.

Scenario 3: A late event changes an aggregate already consumed by a dashboard.

Define whether the aggregate is provisional or final. If the event is within allowed lateness, update the window and use an upsert or correction event so the dashboard reflects the revised result. If it is too late, route it to a correction workflow and clearly document how historical totals are repaired.

Scenario 4: A restart causes duplicate alerts from a stateful application.

Check whether source offsets and operator state restore from the same consistent checkpoint, and whether the alert sink supports idempotency or transactional output. Add a stable alert ID, persist output progress where possible, and test failures between state restoration and external side effects.

Chapter Summary

  • Choose streaming when continuous processing and low latency justify the operational complexity.
  • Distinguish event time, ingestion time, and processing time.
  • Use watermarks and lateness policies to balance completeness, latency, and state retention.
  • Choose window types based on business semantics and understand their state and compute costs.
  • Handle duplicates with stable event IDs, stateful deduplication, and idempotent outputs.
  • Troubleshoot backpressure by identifying the bottleneck, not just adding workers.
  • Recover stateful applications from consistent checkpoints and make sink effects replay-safe.
  • Support corrections when late events change previously emitted aggregates.

Practice Challenge

Design a streaming pipeline that calculates five-minute payment totals and detects suspicious activity. Explain event-time assignment, watermark strategy, window type, duplicate handling, backpressure monitoring, checkpoint recovery, and how you would correct aggregates when late events arrive.

Suggested Blogger post title: Top 8 Stream Processing Interview Questions for Data Engineers | Watermarks, Windows and State

Comments

Popular posts from this blog

Tricky Questions or Puzzles in C ( Updated for 2026)

Updated for 2026 This article was originally written when C/C++ puzzles were commonly asked in interviews. While such language-specific puzzles are less frequent today, the problem-solving and logical reasoning skills tested here remain highly relevant for modern Software Engineering, Data Engineering, SQL, and system design interviews . Why These Puzzles Still Matter in 2026 Although most Software &   Data Engineering interviews today focus on Programming, SQL, data pipelines, cloud platforms, and system design , interviewers still care deeply about how you think . These puzzles test: Logical reasoning Edge-case handling Understanding of execution flow Ability to reason under pressure The language may change , but the thinking patterns do not . How These Skills Apply to Data Engineering Interviews The same skills tested by C/C++ puzzles appear in modern interviews as: SQL edge cases and NULL handling Data pipeline failure scenarios Incremental vs ...

Programs and Puzzles in technical interviews i faced

I have attended interview of nearly 10 companies in my campus placements and sharing their experiences with you,though i did not got selected in any of the companies but i had great experience facing their interviews and it might help you as well in preparation of interviews.Here are some of the puzzles and programs asked to me in interview in some of the good companies. 1) SAP Labs I attended sap lab online test in my college through campus placements.It had 3 sections,the first one is usual aptitude questions which i would say were little tricky to solve.The second section was Programming test in which you were provided snippet of code and you have to complete the code (See Tricky Code Snippets  ).The code are from different data structures like Binary Tree, AVL Tree etc.Then the third section had questions from Database,OS and Networks.After 2-3 hours we got the result and i was shortlisted for the nest round of interviews scheduled next day.Then the next day we had PPT of t...

Decorators in Python

Decorators provide additional functionality to the functions without directly changing their definition of them. Basically, it takes the functions as an argument, adds functionality to them, and returns it.  Before diving deep into the concept of Decorators, let's first try to understand  What are functions in Python and what is an inner function? In Python everything is Objects, be it Class, Variables, and Functions . So functions are python first-class objects that can be used or passed as an argument. You can store the functions in variables, you can pass a function to another function as parameters, and you can also return the function from the function. Below is one simple example where we are treating functions as objects . def make_me_lowercase ( str ): return str .lower() print (make_me_lowercase( "HELLO World" )) copy_of_you = make_me_lowercase print (copy_of_you( "HELLO World" )) The output of the above calls for both the functio...