System Design · hard · Asked at Stripe

Events can arrive up to 48 hours late. How do you handle that in a daily aggregation?

Asked in Data Engineer interviews, in the System Design round.

Short answer

Partition by event time, not ingestion time, and reprocess a trailing window — re-run the last few days each night so late events land in the day they actually belong to. The alternative is a watermark plus published corrections. Either way, state the tradeoff out loud: you wait and are complete but late, or publish early and restate. Bucketing by ingestion time is what makes the warehouse and the source system disagree, and nobody can tell you why.

How to answer it

Aggregate by the time the event happened, not the time it arrived, and accept that a day's number is not final until the lateness window has passed.

Two designs, and you should say which one the consumer needs:

-- nightly: replace the trailing window, partitioned by event time
DELETE FROM daily_events WHERE event_date >= CURRENT_DATE - 3;
INSERT INTO daily_events
SELECT event_date, COUNT(*) FROM raw_events
WHERE event_date >= CURRENT_DATE - 3
GROUP BY event_date;

Then say the consumer-facing part: the dashboard should mark the last two days as provisional, so nobody escalates a "drop" that is just lateness. And measure lateness itself: if the 99th percentile creeps past 48 hours, the window is wrong and the numbers are quietly incomplete.

Related questions

Practice this for real