Data Pipeline Architecture and Design Questions
End-to-end design of data pipelines: source-to-sink flow, staging layers, idempotency, backfills, and reprocessing. Covers choosing between batch and streaming stages, decoupling ingestion from transformation, and designing for evolvability. The foundational systems-design skill for a data engineering interview.
You discover an upstream bug corrupted a key metric for the last 90 days. Design a backfill to correct the historical data without breaking the dashboards and reports that are actively being used right now.
Sample Answer
Direct answer
Recompute the corrected 90 days into a separate staging area using the fixed transform logic, verify the staged output against the current live data with automated checks, then swap the corrected partitions into place atomically, one bounded time window at a time, so dashboards keep reading a consistent, even if briefly stale, version throughout and never see a half-recomputed state.
Structured elaboration
Why staging plus atomic swap, not in-place correction
Correcting rows in place while dashboards are live means any query that runs mid-correction sees a mix of old and new values for the same metric, which is worse than being uniformly wrong. Writing the corrected 90 days to new, parallel storage and only swapping the read pointer once a whole window is verified keeps every read consistent: either the old, known-wrong-but-internally-consistent version, or the new, corrected-and-verified version, never a blend of both.
Windowing the backfill
Recompute in bounded time chunks rather than all 90 days at once. Each chunk gets verified and swapped independently, so a defect found partway through does not block chunks already verified, and a bug in the fix itself is caught on one small chunk before it has been applied to all 90 days.
Determinism is a precondition, not a nice-to-have
Before touching real data, confirm the corrected transform is deterministic: recomputing the same input window twice, same code, same raw input, must produce identical output. This matters just as much when the corrected logic is a code-driven feature transform feeding a model as when it is a simple metric aggregation: either way, running the backfill twice or out of order must not silently recompute the same window into two different results. If the fix relies on anything time-dependent or order-sensitive, such as a default that reads the current time, or an aggregation whose result depends on processing order, running the backfill twice or out of order produces different corrected values, which defeats the audit trail this whole design is trying to establish. Confirm reproducibility on one chunk before running the rest.
Verification before swap
Compare staged output to current live output for the same window on row counts, key aggregate totals (with the specific corrected metric expected to differ and every other metric expected to match exactly), and referential completeness, checking that the fix introduced no orphaned keys. Only swap a chunk once its verification passes; a failed chunk stays on the old, wrong data until investigated, without blocking chunks that already passed.
Communication as part of the design
Since dashboards stay live throughout, tell stakeholders which historical dates are still on the old, known-wrong numbers and which have already swapped to corrected values, so nobody draws a conclusion from a number mid-flight.
flowchart LR
Raw[Raw immutable source] --> Fix[Corrected transform logic]
Fix --> Staging[(Staging: recomputed partitions)]
Staging --> Verify{Verification checks pass?}
Verify -- Yes --> Swap[Atomic partition swap]
Verify -- No --> Retry[Investigate and re-run]
Swap --> Live[(Live tables: dashboards keep reading)]
Worked example
Assume the corrupted metric is computed from roughly 50 million source rows per day:
50,000,000 rows/day×90 days=4.5 billion rows to recompute
Chunking the backfill into 7-day windows:
90 days÷7 days/batch=12.86⇒13 batches (last one partial, 6 days)
which puts roughly
13 batches4.5×109 rows≈346 million rows per batch
a size the verification step needs to run against once per batch, thirteen times total, rather than once against the full 4.5 billion rows, which is what makes an early bug in the fix cheap to catch instead of expensive.
Trade-offs & pitfalls
- Correcting live tables in place, even for "just one column," is not atomic from a concurrent reader's point of view unless the store guarantees it, and most analytical stores do not at the row level during a bulk update.
- Running all 90 days as one giant job means a bug discovered on day 60 requires redoing all 90, instead of redoing one already-isolated chunk.
- Smaller chunks catch problems earlier and reduce blast radius but add coordination overhead (more swap events, more verification runs); chunk size should track how much the fix is trusted, not a fixed default.
- Skipping the determinism check because the fix "looks simple" is a common wrong turn; a fix that is not reproducible turns the audit trail, what changed, why, and by how much, into something nobody can reconstruct later.
What's the difference between a data lake and a data warehouse, and how would a pipeline typically use each as it moves data from source to sink?
Sample Answer
Direct answer
A data lake stores raw and semi-structured data cheaply with schema-on-read, optimized for ingest scale and flexible reprocessing; a data warehouse stores curated, modeled data with schema-on-write, optimized for fast, governed, repeated SQL access. In a source-to-sink pipeline, the lake is typically where raw data lands first and stays as the reprocessing archive, while the warehouse (or a warehouse-modeled zone) is the layer BI tools and dashboards actually query.
Structured elaboration
Core distinction
| Aspect | Data lake | Data warehouse |
|---|---|---|
| Schema | Schema-on-read | Schema-on-write |
| Data shape | Raw, semi- or unstructured, any format | Curated, structured, modeled |
| Cost profile | Cheap object storage, compute billed separately | Storage and compute often tuned together for repeat queries |
| Primary consumer | Engineers and scientists, batch reprocessing | Analysts and BI tools, repeated dashboard queries |
| Query performance | Variable, needs a compute engine layered on top | Tuned for fast, repeated, well-modeled queries |
| Governance | Needs active governance or becomes unmanageable | Governance is largely built into the modeled schema |
How a pipeline threads them together
Ingestion lands raw events in the lake first, immutable and partitioned by arrival time, regardless of downstream shape, because that is the cheapest point to keep full fidelity and reprocess later if logic changes. A transformation stage then cleans, conforms, and models that data into the warehouse (or a warehouse-modeled zone), which is what BI and reporting query directly. The lake stays the archive and reprocessing source; the warehouse stays the fast, governed read path. Ad-hoc exploration of raw signals goes to the lake; repeated, latency-sensitive dashboard queries go to the warehouse.
The lakehouse alternative for regulated, audit-heavy settings
In a regulated environment where every read must be auditable and data cannot be duplicated across stores without tight control, a lakehouse pattern collapses the two zones into one: transactional table formats built directly on lake storage add warehouse-like properties (atomicity, consistency, isolation, durability, plus versioning and schema enforcement) to the lake itself, so there is a single lineage instead of two copies to reconcile for an audit. The trade is fewer warehouse-specific conveniences (workload isolation, some query-engine optimizations) in exchange for one authoritative copy.
Worked example
Consider a pipeline handling clickstream and change-data-capture (CDC) feeds from an operational database. Both land in the lake first as immutable, partitioned files, preserving full history even though the operational source only keeps a live snapshot. A daily transform job conforms and models that data into warehouse tables for a daily-active-user dashboard. If a support ticket needs a raw event from three weeks ago that never made it into any warehouse table, the lake still has it; the warehouse never needed to carry that raw volume at all. In a regulated variant of the same pipeline, the raw and modeled tables would instead live as transactional tables on the same lake storage, so the audit trail for "who read what, when" does not have to be reconciled across two separate systems.
Trade-offs & pitfalls
- Treating the lake as if it were queryable at BI speed is a common mistake; a lake needs a compute engine layered on top, and querying raw files directly for dashboards gets slow and expensive fast.
- Skipping the lake and loading straight into the warehouse loses reprocessing ability, forcing a re-pull from the original source if transformation logic ever needs to change.
- Warehouse compute and storage coupling can get expensive at high ingest volume; many pipelines route only aggregated, curated data to the warehouse and leave raw exploration to the lake.
- A lakehouse is not a universal upgrade. It earns its keep specifically when audit simplicity or a hard constraint against duplicating regulated data outweighs the workload-isolation and tuning conveniences a separate warehouse provides.
What is medallion (bronze/silver/gold) layering in a data pipeline, and what job does each layer do?
Sample Answer
Direct answer
Medallion layering organizes a lakehouse into three progressively refined storage layers: bronze holds raw data exactly as it arrived, append-only and unvalidated; silver holds cleaned, deduplicated, and conformed data still close to the source's row-level grain; and gold holds business-level aggregates and marts shaped for direct consumption by dashboards and analysts. Each layer's job is to isolate a different kind of change, source format drift, cleaning-logic bugs, business-definition changes, so fixing one kind of problem only requires reprocessing from the layer below it, not re-ingesting from the original source.
Structured elaboration
Bronze (raw). Ingested as-is from the source, whatever format it arrives in, append-only, tagged with ingestion metadata (source, timestamp, batch identifier), with no business logic applied. Its job is to be the durable, replayable record of exactly what arrived, so that if a downstream bug is found months later, it can be reprocessed without hitting the source system again.
Silver (cleaned and conformed). Parses and validates bronze, deduplicates, standardizes types and null handling, applies a schema, joins to reference or dimension data, and resolves late-arriving or out-of-order records. Still roughly one row per source record. Its job is to give every downstream consumer one trusted version of what the data means, instead of every team re-implementing its own cleaning logic against raw bronze.
Gold (curated, business-level). Aggregates and denormalizes silver into tables shaped for a specific consumption pattern, a business intelligence dashboard, an ML feature set. Its job is to encode business definitions, what counts as an active user, how revenue is recognized, in one governed place rather than scattered across every consumer's own query.
Why layer at all. Each layer isolates a distinct failure or change domain. A source schema change only requires a bronze or silver fix, not a full re-ingest. A redefinition of a business metric only touches gold, not the whole history underneath it. Reprocessing a layer replays from the layer directly below it, which is what makes iterative fixes cheap instead of full-pipeline reruns.
flowchart LR
S[Source systems] --> Br[Bronze: raw, append-only]
Br --> Si[Silver: cleaned, deduped, conformed]
Si --> Go[Gold: business aggregates and marts]
Go --> BI[Dashboards / BI tools]
Br -.reprocess.-> Si
Si -.reprocess.-> Go
Worked example
A source system emits 50 million raw events per day into bronze, roughly 2 KB per event, appended without filtering:
50,000,000×2 KB=100,000,000 KB≈100 GB/day (bronze)Silver deduplicates retries (say 2% of events are duplicate deliveries) and joins to a customer dimension:
50,000,000×(1−0.02)=49,000,000 unique, typed events 49,000,000×500 B≈24.5 GB (silver, columnar-compressed)Gold aggregates this down to one row per customer per day. If 3,000,000 distinct customers were active that day, gold's daily table has 3,000,000 rows. A dashboard that queried silver directly on every refresh, at roughly 50 bytes per aggregate row it actually needs, would scan far more than necessary:
3,000,000×50 B24.5×109 B≈163× more bytes scanned than gold requiresThat ratio is the concrete reason gold exists as its own layer rather than letting every dashboard query silver directly.
Trade-offs & pitfalls
Skipping silver and going straight from bronze to gold means every gold table re-implements its own cleaning and deduplication logic, so three marts built by three teams can quietly disagree on something as basic as how many customers were active on a given day, because their bespoke cleaning diverged. Over-layering, adding a fourth or fifth stage without a distinct kind of change to isolate, adds storage and pipeline hops without buying anything; the right number of layers is however many genuinely different failure domains exist, not a mandatory three. Bronze must stay genuinely raw and immutable: the moment "a little cleaning" is quietly applied on the way into bronze for convenience, the replay guarantee that is the entire point of the layer is lost.
What's the difference between partitioning and bucketing a large table in a pipeline's storage layer, and when would you reach for each?
Sample Answer
Direct answer
Partitioning splits a table into separate physical directories or files by a column's value, most often a date, so a query that filters on that column can skip reading the partitions it does not need. Bucketing (also called clustering) instead hashes rows into a fixed number of files within a table or partition; it does not let a query skip data by value, but it gives predictable, evenly sized files that make joins and sampling on the bucketed key cheaper.
Structured elaboration
| Partitioning | Bucketing | |
|---|---|---|
| Physical layout | one directory per distinct value | a fixed number of hash buckets |
| Main benefit | partition pruning: skip irrelevant data entirely on read | reduced shuffle for joins on the bucket key, deterministic sampling |
| Fits best | low- to medium-cardinality columns most queries filter on (date, region) | higher-cardinality keys used mainly in joins or aggregations (a user identifier) |
| Failure mode if over-applied | too many tiny partitions: huge file and metadata count, slow query planning | wrong bucket count, or a skewed key, produces unevenly sized buckets |
| Reach for it when | most queries filter on this column | the expensive queries join, aggregate, or sample on this column, ideally with both sides of a join bucketed the same way |
Worked example
Take an events table retained for 3 years. Partitioning by day gives:
3×365=1,095 partitions
a manageable number for a query planner to reason about. Partitioning the same table at millisecond granularity instead would attempt roughly:
3×365×86,400,000≈9.46×1010 partitions
an unusable number, the metadata overhead alone would dwarf the actual data. Bucketing sidesteps this failure mode entirely because the bucket count is fixed regardless of the time range covered. Bucketing the same table by a user identifier into 256 buckets instead means a query joining it to another table also bucketed into 256 buckets on the same key can match buckets directly, rather than shuffling and comparing every row against every other row.
Trade-offs & pitfalls
Over-partitioning, as the millisecond example shows, explodes metadata and small-file count well past the point of being useful. Partitioning on a column most queries never filter on wastes the pruning benefit and just fragments storage for no gain. Bucketing without matching bucket counts on both sides of a join gets none of the intended benefit. A skewed bucket key, where a handful of values generate most of the rows, produces a few oversized buckets, the bucketing analog of a hot partition. The senior move is usually coarser partitions (day, not millisecond) combined with bucketing or periodic compaction for the finer-grained access pattern, rather than partitioning at the finest grain "just in case."
A stakeholder wants a dashboard that reflects activity within the last few minutes, but you're currently running nightly batch jobs. Would you move the whole pipeline to streaming, keep it batch, or build a hybrid, and what would that hybrid look like?
Sample Answer
Direct answer
Neither a full migration to streaming nor leaving the pipeline as nightly batch is usually right: keep the batch pipeline as the accurate, full-history layer for aggregates that don't need to be fresh, and add a narrow streaming or micro-batch layer that only serves the last few minutes of activity, presented alongside the batch results at the dashboard layer. This mirrors a lambda-style split: completeness comes from batch, freshness comes from a small, disposable fast path.
Structured elaboration
Deciding the split, not just "streaming vs batch"
Start by asking which numbers on the dashboard actually need last-few-minutes freshness. Usually it's a small subset (an "activity right now" tile), while most historical trend lines are fine refreshed nightly. If the real need is a mixed view, a near-real-time operational tile alongside a daily executive summary, design for that multi-tier freshness explicitly: the operational tile gets the streaming path, the executive summary keeps reading from the nightly batch layer, and both are labeled with their own freshness so nobody mistakes a provisional number for the reconciled one.
The hybrid architecture
Ingestion fans the same raw event stream into both paths: continue landing to the existing batch source, and also publish to a durable, ordered log for the fast path. A lightweight streaming or micro-batch job computes short-window aggregates from that log and writes them to a low-latency store the dashboard queries for the "right now" tile; this path is deliberately narrow, covering only the metrics that need sub-hour freshness. The existing nightly batch job keeps computing the full, reconciled aggregates exactly as it does today, feeding historical trend lines and the executive summary. The dashboard layer, not the pipeline, stitches the two together: either as clearly separate panels with different "as of" timestamps, or by having the fast path's numbers get superseded once batch recomputes the same period, so there is a single definition of "final" per period.
flowchart LR
Src[Event source] --> Batch[Nightly batch pipeline]
Src --> Stream[Streaming or micro-batch layer]
Batch --> Historical[(Historical aggregates)]
Stream --> Recent[(Recent-minutes aggregates)]
Historical --> Dash[Dashboard: unified view]
Recent --> Dash
Sizing the fast path
If the source runs at roughly billion-scale volume per day, the fast path has to be sized for sustained throughput, not just for how often the dashboard is queried.
Worked example
86,400 s1,000,000,000 events≈11,574 events/sec average
11,574×5≈57,870 events/sec at a 5x peak-to-average ratio
That average-to-peak sizing determines whether the fast path needs a horizontally scaled stream processor or whether a simpler scheduled micro-batch clears the bar. A stakeholder asking for "the last few minutes" rarely needs true per-event streaming; a micro-batch cadence of one to two minutes usually satisfies that freshness bar at a fraction of the operational cost of a fully event-driven path, and is the first thing worth trying before committing to full streaming infrastructure.
Trade-offs & pitfalls
- Migrating the entire pipeline to streaming to fix one dashboard tile multiplies operational surface (state management, backpressure, monitoring) for freshness the majority of metrics never asked for.
- Serving the fast path's numbers without labeling them as provisional costs trust: when the nightly batch later reconciles the same period and the number moves, stakeholders need to have been told upfront that the recent window was an estimate.
- Running two computation paths, even a narrow fast path alongside the existing batch path, reintroduces lambda-style risk of logic drift between them; keep the fast-path aggregation as close as possible to the batch definitions to avoid two different answers for the same hour.
- Sizing the fast path for peak load only, or average load only, is a common wrong turn; design for the peak-to-average ratio, since a fast path that falls behind during a burst defeats the purpose of the freshness guarantee.
Unlock Full Question Bank
Get access to all 31 Data Pipeline Architecture and Design interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.