How Data Moves: Advanced
What you will be able to do
How the question arrives
Diagnose before you fix
| Step | What run 2 does | Idempotent? |
|---|---|---|
| INSERT INTO fact_orders SELECT ... FROM staging | adds the same 50,000 rows again | No |
| DELETE the partition, then INSERT it | removes run 1's rows, writes identical rows | Yes |
| UPDATE totals SET revenue = revenue + delta | adds the delta a second time | No |
| Write orders/dt=2024-11-24/part-0.parquet | overwrites the same path | Yes |
| Call the payment API to capture a charge | charges the customer twice | No, unless keyed |
The 3 production patterns
Each node carries its own idempotency strategy, so a retry at any point replays safely
Where the follow-up goes
- Name the exact step that breaks under a second run before proposing any fix
- Derive the partition from the run's logical date so backfills replay the same slice
- Put an idempotency key on every call that leaves the warehouse
- State the retention of any dedup id store
- Say 'add deduplication' without saying what produces the duplicates
- Compute aggregates as target plus delta
- Generate surrogate keys from a sequence inside a retryable task
- Claim exactly-once when you mean an idempotent write
Recognizing the question
The 4 places the pressure can go
| Where the gap goes | Mechanism | What it costs | Fits when |
|---|---|---|---|
| Buffer | log retention on disk, bounded in-memory ring | latency grows with lag, storage | the burst is short and every event must survive |
| Producer slows | blocking send, credit-based flow control, HTTP 429 with Retry-After | upstream latency, upstream memory risk | the producer can hold state, such as a batch extractor |
| Consumer speeds up | more partitions and instances, larger fetch batches, async I/O | money, rebalance pauses, capped by partition count | the rate increase is sustained |
| Drop or sample | shed oldest, keep 1 in N, priority lanes | data loss, biased metrics | telemetry where the trend matters more than each point |
The number that decides it
Bounded versus unbounded
Lag is the metric, retention is the deadline, partition count is the ceiling on the fix
What a top answer sounds like
- ▸What if the slow consumer is a database? Batch the writes, raise the commit size, and put a buffer with retention in front of it.
- ▸Does the producer know it is being throttled? It must receive a signal it can act on, or it will time out and retry into the same congestion.
- ▸How long until lag clears? Lag divided by the surplus rate: 40 million at a 2,000 per second surplus is about 5.6 hours.
One question, 3 costs
Latency: the speed of light is the floor
| Route | Typical round trip | 50 sequential round trips |
|---|---|---|
| Same region, across zones | 1 to 2 ms | 0.1 s |
| US east to US west | 60 to 70 ms | 3.3 s |
| US east to Frankfurt | 80 to 100 ms | 4.5 s |
| US east to Singapore | 180 to 220 ms | 10 s |
Egress: the bill for every byte that leaves
- Every downstream query becomes possible in region 2
- Egress scales with event volume
- Lag of seconds with a log-based stream
- Doubles storage and doubles the compliance surface
- Only the agreed outputs cross the boundary
- Egress scales with aggregate size, often 100x smaller
- Lag equals the batch cadence
- A schema change in the aggregate is a cross-region contract
Consistency: what the other region sees
The residency twist
Counting the places data is exposed
In transit: stated precisely
Masking, hashing, tokenizing: pick by what survives
| Technique | Joins survive? | Reversible? | Weakness |
|---|---|---|---|
| Masking | No | No | useless for analytics joins |
| Keyed hash (pepper) | Yes | No | a leaked key exposes every low-entropy field |
| Tokenization | Yes | With vault access | the vault is a single high-value target |
| Field encryption | Only on ciphertext equality | With key access | key rotation means re-encrypting history |
Where the masking happens is the scope question
- Count the leak points: wire, staging, broker disk, DLQ, logs, errors, backups, exports
- Pseudonymize at ingest with a keyed hash so joins survive
- Hold raw identifiers in a separate table with its own policy and retention
- Answer deletion against immutable logs with per-customer keys
- Stop at 'we use TLS' when asked where data is exposed
- Hash a phone number without a secret key
- Let a stack trace print a row into the orchestrator's logs
- Forget that the dead-letter queue holds the same fields as the main topic
The question is a budget question
The freshness ladder and what each rung costs
| Cadence | Runs per day | Compute shape | Hidden cost |
|---|---|---|---|
| Daily batch | 1 | 1 cluster, 45 min | worst-case staleness of 25 h |
| Hourly batch | 24 | 1 cluster, 5 min each | 24x the scheduling surface, late data straddles hours |
| 5-minute micro-batch | 288 | warm cluster or always-on pool | small files, a compaction job, lag alerts |
| Streaming | continuous | always on, sized for peak | 2 code paths if batch backfill stays, checkpoint operations |
The cost of small files
Placing the use case
| Use case | Who acts, how fast | Right cadence | Why |
|---|---|---|---|
| Fraud scoring at checkout | a model, inside the request | streaming | the decision happens inside the latency window |
| Live sales globe on a marketing page | nobody acts, it is a display | streaming, sampling allowed | the value is the motion, so dropped events are acceptable |
| Executive revenue dashboard | humans, at a daily standup | hourly or daily | the decision cadence is daily |
| Inventory reorder | a planner, each morning | daily, plus a hot path for stockouts | split the 1 urgent signal from the bulk |
| Experiment metrics | a PM reading results after a week | daily | nothing changes faster than the experiment |
Saying it in the room
- ▸A question back about who consumes the data and how fast they act on it
- ▸How busy the cluster is: the one that runs 45 minutes a day against the one that never stops
- ▸The small files that micro-batches write and the compaction job they force, raised before being asked
- ▸A split design: bulk in batch, the 1 urgent signal in a narrow stream
- ▸A freshness SLA with a number and an owner, plus a rule for late data
> DoorDash on Super Bowl Sunday: order volume climbs through the afternoon and spikes in the hour before kickoff, and the data platform has to keep a courier-supply dashboard fresh for dispatch operators in several countries, feed a fraud model inside the checkout request, and hand the finance team a settlement table the next morning that reconciles to the cent, all while the orchestrator retries whichever extract times out under the load.
The senior-round pipeline questions: retries, overload, regions, secrets and the price of now.
- Category
- Pipeline Architecture
- Difficulty
- advanced
- Duration
- 30 minutes
- Challenges
- 4 hands-on challenges
Topics covered: Idempotent Pipelines, Backpressure, Cross-Region Data Replication, Moving Sensitive Data Safely, Cost of Freshness
Lesson Sections
- Idempotent Pipelines
How the question arrives The interviewer rarely says the word idempotent. The question shows up as a story: the orchestrator retried the 02:00 load at 02:40 after a timeout, and finance now sees revenue 1.8 times what the ledger shows. Or it is framed as a design prompt: this job writes to the fact table, what happens if it runs twice? Both are the same question. The score comes from 2 things in order: first the diagnosis of where a second run changes the result, then the pattern that removes th
- Backpressure
Recognizing the question It arrives as a graph described in words. 'Consumer lag on the orders topic has been climbing since 09:00 and is now at 40 million events.' Or as a design probe: 'the API ingests 10,000 events per second but the enrichment service handles 6,000, what do you do?' The interviewer is testing whether you treat the gap as arithmetic before treating it as an incident. A shortfall of 4,000 per second is 14.4 million events of lag per hour, and the first sentence of a strong ans
- Cross-Region Data Replication
One question, 3 costs The prompt sounds operational: 'our warehouse is in Virginia, the new analytics team sits in Frankfurt, the dashboards feel slow, should we replicate?' Or it comes from compliance: 'EU customer data must stay in the EU, how does the global dashboard still work?' Either way the interviewer wants 3 costs separated and a number on each: round-trip latency, which physics sets; egress fees, which the cloud bill sets; and consistency, which your replication design sets. An answer
- Moving Sensitive Data Safely
Counting the places data is exposed It arrives as a review: 'walk me through how customer data moves from the checkout service to the analytics warehouse, and tell me where it is exposed.' The word exposed is the hint. The interviewer holds a mental list of places personal data leaks while it moves and is counting how many you find. The list runs longer than encryption: the wire, the staging bucket, the broker's disk, the dead-letter queue, the orchestrator's logs and the error message that prin
- Cost of Freshness
The question is a budget question It arrives as enthusiasm from the product side, repeated by the interviewer: 'the executives want the revenue dashboard in real time, how would you build it?' The scored answer begins with a question back: what decision does anyone make from this number, and how fast do they make it? If the dashboard is read at the 09:30 standup, 15-minute freshness is indistinguishable from 1-second freshness, and the difference in cost is where the judgement shows. The intervi