Data Pipeline Scalability and Performance Questions
Diagnosing and fixing throughput, cost, and capacity problems in data pipelines: batch ETL/ELT jobs and streaming ingestion that must handle growing data volume within cost and SLA constraints. Covers bottleneck diagnosis (I/O-bound versus CPU-bound stages, profiling a slow pipeline); partition and key design as a load-distribution DECISION for a processing job (choosing keys, avoiding and mitigating hot partitions); recognizing when a transformation forces an expensive shuffle or join and choosing a mitigation strategy at the decision level, not engine-internal tuning; capacity planning anchored in real data volume (cluster, storage, and network sizing from an event rate and payload profile); and throughput techniques including incremental processing, result caching and materialization, storage-format and compaction choices for throughput, and cost-efficient scaling (autoscaling policy, spot/reserved capacity trade-offs). Also covers multi-tenant resource governance for shared data-processing infrastructure (quotas, isolation, throughput enforcement). Distinct from distributed-data-processing-with-spark-and-hadoop (engine-internal execution mechanics of a specific framework), data-reliability-and-fault-tolerance (correctness and consistency guarantees under failure, e.g. exactly-once semantics and checkpointing), workflow-orchestration-and-scheduling (DAG/dependency coordination), and general application or service performance tuning (web request latency, generic distributed-systems architecture with no data-pipeline framing).
A legacy daily ETL job is taking many hours to complete and blocking analytics. Explain how you'd decide whether to rewrite it in Spark, optimize the SQL, or change to incremental loads. Include evaluation criteria, estimated ROI, risk assessment, and rollout approach.
Sample Answer
Direct answer. Deciding between rewriting a slow legacy job in a distributed framework, optimizing the existing SQL, or moving to incremental loads is a cost/risk decision, not a pure technical one: optimize the SQL first if a cheap win is plausible, move to incremental processing if the job's core problem is reprocessing unchanged data, and reserve a full rewrite for when neither of those addresses the actual bottleneck.
Structured elaboration.
- Evaluation criteria to gather first. Where does the time actually go (a stage-by-stage profiling pass across ingest, transform, and write, to find which part of the job actually dominates runtime) -- a slow SQL query, a slow full-table scan that incremental processing would shrink, or fundamental single-engine limitations that only a distributed rewrite fixes. Without this, the choice is a guess dressed up as a decision.
- SQL optimization is the cheapest option to TEST (often a config or query change with no architectural risk) and should be tried first whenever profiling shows the bottleneck is a specific slow query rather than the job's overall structure -- missing indexes, a suboptimal join order, or an unnecessarily wide
SELECT *are common, cheap-to-fix causes. - Incremental loads address a different problem: a job that is slow because it reprocesses the FULL dataset every run when only a small fraction changed. This is the right move when profiling shows most of the runtime is proportional to total table size rather than to the amount of actually-changed data (the signature that favors moving to incremental, delta-only processing over a full-table rebuild every run).
- A full rewrite to a distributed framework (e.g., moving single-node SQL processing to Spark) is justified when the DATA VOLUME itself has outgrown what a single engine can process within the SLA regardless of query or incremental optimization -- this is the most expensive and highest-risk option and should be the last one considered, not the first instinct.
- Estimated ROI and risk assessment. For each candidate fix, estimate: expected runtime improvement (ideally validated against a profiling-informed hypothesis, not a guess), implementation effort, and RISK of introducing a correctness bug (a rewrite touches the most code and carries the highest correctness risk; a config/index change touches the least).
- Rollout approach. Whichever option is chosen, validate against the existing job's output (row counts, sample-row diffs, aggregate checksums) on a comparable data volume before cutting production traffic over, and keep the prior job runnable as a fallback until the new version has proven itself over several real runs.
Worked example. Profiling a slow legacy job shows 85% of runtime is spent scanning the full source table even though only about 4% of rows changed since the last run. This strongly favors incremental loads over either SQL tuning (which would only shave time off the SAME full scan, not eliminate the unnecessary work) or a distributed rewrite (which would process the full table faster but still reprocess data that did not need reprocessing at all -- solving the wrong problem more expensively). The ROI case: incremental loads plausibly cut runtime by a factor close to 1/0.04 = 25x for the read-and-transform portion of the job, versus a distributed rewrite that might only achieve a 3-5x speedup on the SAME unnecessarily-large workload for a much larger engineering investment.
Trade-offs & pitfalls. A common mistake is reaching for a full rewrite because it feels like the 'real' fix, when the actual bottleneck (as in the worked example) is architectural inefficiency (reprocessing unchanged data) that a rewrite does not address at all -- always let the profiling data, not intuition about which fix sounds most substantial, drive the decision. Conversely, do not dismiss a rewrite reflexively either: if the profiling clearly shows the JOB'S CORE LOGIC (not incidental reprocessing) exceeds what a single engine can do within budget as volume grows, incremental loads alone will eventually hit the same wall, just later.
Design a backpressure-control mechanism that coordinates across Kafka producers, brokers, and Spark Structured Streaming consumers to gracefully handle bursts without data loss. Describe the control signals, algorithms (e.g., token buckets, feedback loops), how the system surfaces pressure to producers, and how to guarantee durability during slowdowns.
Sample Answer
Direct answer. Cross-system backpressure spanning brokers, stream processors, and multiple downstream sinks needs the signal to propagate END-TO-END (not stop at the first hop), with each hop able to shed gracefully for non-critical traffic rather than blocking everything uniformly, and explicit fairness rules so one slow tenant or one struggling sink cannot silently starve everyone else.
Structured elaboration.
- Detection metrics at each hop. Consumer lag (broker to processor), processing-queue depth (within the processor), and sink write latency/error rate (processor to sink) -- each hop needs its OWN local signal, because a slowdown detected only at the final sink gives no early warning at the earlier hops.
- Propagation mechanism. A slow sink should cause the processor to slow its consumption from the broker, which in turn causes broker-side consumer lag to grow, which (if the broker itself surfaces this signal to producers, e.g., via a token-bucket credit protocol (the broker grants producers a bounded number of send credits, replenished over time) or an explicit throttle-response feedback loop (the broker reports its current pressure and producers adjust their rate accordingly)) should eventually slow the original producer. Each hop's local backpressure signal becomes the trigger for the NEXT hop upstream to apply its own backpressure, rather than each hop independently guessing when to throttle.
- Graceful degradation for non-critical traffic. Not all traffic deserves equal treatment under pressure: tag traffic by criticality (e.g., a 'critical events' class vs 'best-effort analytics' class) so that under sustained pressure, the system sheds or delays the best-effort class first, preserving throughput for critical traffic. This requires the propagation mechanism above to be QUEUE-AWARE, applying backpressure selectively rather than uniformly.
- Avoiding unfair throttling across tenants. A single misbehaving or overloaded tenant/producer should not cause the backpressure signal to throttle EVERY producer equally; per-tenant rate awareness (or per-tenant queues) at the point where backpressure is applied prevents one tenant's slowdown from becoming everyone's problem.
- Operator playbook for incidents. A clear escalation path: which dashboards show the propagation chain end-to-end (so an operator can see at a glance which hop is the original source of pressure, not just where the symptom is loudest), what manual interventions are safe (scaling a specific hop, temporarily shedding a specific traffic class), and what to communicate to stakeholders if degradation is expected to be visible (e.g., delayed non-critical analytics).
- Guaranteeing durability during the slowdown. Backpressure only avoids data loss if it SLOWS acknowledgment rather than DROPS messages, and that has to be true at every hop: on the Kafka side, producer
acks=all(or an equivalentmin.insync.replicassetting) means a message is not considered sent until it is replicated, so a producer that is being throttled simply sends less often, never loses an already-acknowledged message; the broker's own retention window then becomes the outer durability bound, since an unread message only survives as long as retention allows, so retention must be sized longer than the worst-case backpressure episode (the same sizing exercise you would run for buffer capacity) or a sufficiently long slowdown can let a consumer's offset fall out of the retention window and lose unread data even though nothing was ever technically 'dropped' by the pipeline itself. On the Spark Structured Streaming side, checkpointing (the offset log plus processed-state) must only advance PAST a micro-batch after that batch's output is durably written, so a restart during a slowdown resumes from the last successfully processed offset rather than either replaying already-written data or skipping unprocessed data. Combined with step 3's priority-lane design, 'graceful degradation' for best-effort traffic means DELAYED, not dropped: it sits in its own durable queue/topic accumulating (subject to the same retention math above), which is what actually keeps the whole design consistent with the 'without data loss' requirement rather than quietly redefining low-priority loss as acceptable.
Worked example. A downstream OLAP sink starts rejecting writes under its own load spike. Detection: sink write-error rate crosses threshold. Propagation: the stream processor, seeing rising write failures/latency to that sink, stops pulling new messages from the broker at its previous rate, which shows up as growing consumer lag on that processor's consumer group. If the broker surfaces consumer-lag-driven throttling to producers (or if producers themselves monitor broker-side lag), the original producers slow their send rate. Meanwhile, the critical-events traffic class continues flowing at full rate throughout (its own dedicated queue/priority lane is unaffected), while best-effort analytics traffic is the one actually delayed, matching the intended degradation priority.
Trade-offs & pitfalls. Building a genuinely end-to-end propagation chain is significantly more engineering effort than local, per-hop backpressure, and the added complexity (priority classes, per-tenant fairness, cross-hop signal propagation) is only worth it once a real incident has shown that local-only backpressure fails to protect what matters -- for a lower-stakes pipeline, local backpressure at each hop independently (without full end-to-end propagation) is a legitimate, simpler starting point. Flink-specific implementations add operator-level knobs (network buffer sizes, operator parallelism, async I/O for external calls) that tune HOW backpressure manifests within one hop, but do not by themselves solve the cross-system propagation and fairness problems described above -- both layers are needed for a genuinely robust system.
A downstream analytics cluster is creating many small Parquet files (tens of thousands per hour) because many parallel writers flush small batches to S3. As a Solutions Architect, design a file-accumulation and compaction strategy that reduces metadata and PUT costs and achieves target Parquet files around 256MB. Include buffering/windowing semantics, atomic commit patterns, failure handling, and how you would maintain near-real-time availability of data.
Sample Answer
Direct answer. Many small Parquet files from parallel writers flushing small batches hurts both metadata overhead (listing/opening many files) and PUT-request cost; the fix has two complementary halves -- change the write path to produce fewer, larger files in the first place (prevention), and run a periodic compaction job to merge already-written small files into targets around a healthy size like 256MB (remediation for what has already accumulated).
Structured elaboration.
- Diagnose before fixing. Confirm small files are actually the cause of the slowdown (not a coincidental symptom) by checking file-count-per-partition against expected row volume, and checking whether query planning time (listing/opening many small files) or actual scan time dominates the observed slowness -- these point to different remedies (the former is purely a file-count problem, the latter may also involve I/O-pattern issues).
- Prevent-at-ingestion (buffering/windowing). Rather than each of the many parallel writers flushing on its own small schedule, introduce a buffering or micro-batching layer that accumulates records across a time window (or size threshold) before flushing, so each flush produces a file closer to the target size. This addresses the ROOT cause rather than only cleaning up after it.
- Atomic commit patterns. When multiple writers commit concurrently, use an atomic commit mechanism (e.g., writing to a temporary location and atomically renaming/registering into the target on completion, or a table format with native atomic multi-file commits) so a target file-size change does not introduce partial-write visibility issues during the transition.
- Compact existing small files. For files already accumulated, run a background compaction job that reads groups of small files within a partition and rewrites them as fewer, larger files near the target size, without disrupting reads in progress (via an atomic swap: build the compacted output alongside the old files, then atomically make it the visible version).
- Maintain near-real-time availability during compaction. Compaction should run on a cadence and batch size that does not meaningfully delay data becoming queryable -- e.g., compacting files older than a short buffer window (say, the last 15-30 minutes) rather than the very newest files, so data remains promptly visible while still eventually landing in efficiently-sized files.
- Failure handling. A writer crashing mid-batch before its flush completes should leave the target in the same state as if that batch never started, since the atomic commit pattern from item 3 already guarantees a partial write never becomes visible. If the compaction job itself fails partway through rewriting a group of small files, readers should keep seeing the original, uncompacted files until compaction succeeds and atomically swaps in the compacted version -- the failure is invisible to readers, not a data-loss event, because the pre-swap files are never deleted until the swap succeeds. A failed atomic rename/registration step (the compaction run's final commit) should be detected by the compaction job's own completion check and retried on the next scheduled run rather than left half-applied; the cost of a failed compaction is a wasted compute cycle, not lost or inconsistent data.
Worked example. Tens of thousands of small files accumulate per hour because dozens of parallel writers each flush independently every few seconds. Introducing a windowed buffering layer (accumulate 200MB or 5 minutes, whichever comes first, per writer) cuts file count roughly proportionally to the increase in per-file size -- if average file size grows from roughly 2MB to 200MB, that is a ~100x reduction in file count for the same data volume, directly reducing both metadata/listing overhead and PUT-request cost. A background compaction job additionally merges any already-small files (from before the buffering change, or from writers that still occasionally flush a partial window) into ~256MB targets on an hourly cadence, applied only to data older than a 30-minute buffer to avoid delaying fresh data's availability.
Trade-offs & pitfalls. Buffering at ingestion trades a small amount of latency (data is not queryable until its buffer window flushes) for the throughput/cost benefit of larger files -- size the window against the pipeline's actual freshness requirement, not arbitrarily. Compaction itself consumes read+write bandwidth and, if run against the SAME storage volumes as live ingestion without isolation or throttling, can itself become a resource-contention problem in its own right, competing with live ingestion for the same disk I/O -- schedule or throttle it deliberately rather than letting it compete uncontrolled with live writes.
Implement checkpointing logic for a simple stateful operator in Python that maintains per-key sums. Provide pseudocode for processing events, snapshotting state atomically to durable storage (e.g., S3), and restoring state on restart. Discuss consistency guarantees and trade-offs for checkpoint frequency.
Sample Answer
Direct answer
A stateful operator maintaining per-key running sums needs three things to checkpoint safely: state and the corresponding input offset checkpointed TOGETHER as one atomic unit (never one without the other), the checkpoint write itself made atomic via a stage-then-publish pattern so a reader (or a restart) never observes a partially-written checkpoint, and a restore step that reads the latest VALID checkpoint and resumes from its recorded offset. Below is a full implementation, executed, proving both correctness (restored state matches ground truth) and atomicity (a checkpoint interrupted mid-write is correctly ignored on restore, never mistaken for valid).
Structured elaboration
Why offset and state are checkpointed as one unit. If state were checkpointed without also recording exactly which input offset it reflects, a restart would not know where to resume reading, risking either reprocessing already-reflected events (double-counting sums) or skipping events the checkpoint does not yet reflect (undercounting), the same general state-and-source-position coupling any checkpoint design needs, applied here concretely to a per-key-sum operator.
Atomic snapshotting. Serialize the full current state to a TEMPORARY file, fsync it, then atomically publish it (here, os.replace, which is atomic on POSIX filesystems: a reader sees either the complete old file or the complete new file, never a partial write mid-replace). This mirrors the guarantee S3 itself gives for a single object PUT: the object is either fully the old version or fully the new version, never observable half-written. No live AWS S3 is used in this sandbox; the local-filesystem stand-in exercises the identical stage-then-atomically-publish logic a real S3 client performs, and this is stated explicitly rather than presented as a live cloud call.
Restoring state on restart. On construction, find the LATEST checkpoint file present (by filename, which encodes the offset it covers) and load it. Because only successfully, atomically published checkpoints ever appear as a checkpoint-NNNN.json file (an interrupted write leaves only a .tmp file, which the restore glob deliberately does not match), restore never accidentally picks up a half-written checkpoint.
Consistency guarantees. The restored state is exactly the state as of the last successfully completed checkpoint, no more, no less: any events processed between that checkpoint and a subsequent crash are lost from the operator's own state (this is why, in a full production pipeline, a WAL sits alongside checkpointing to make that gap recoverable via replay; this exercise focuses on the checkpoint/restore mechanism itself).
Checkpoint frequency trade-offs. More frequent checkpoints bound the gap above tighter (less state lost/needing WAL replay on crash) at the cost of more frequent I/O and, for a full-state snapshot approach like this one (as opposed to an incremental approach that persists only what changed), a write cost that scales with total state size on EVERY checkpoint, which becomes the dominant cost once per-key state grows large, exactly why production systems move to incremental checkpointing once state size crosses that threshold.
Worked example
"""
A stateful operator maintaining per-key running sums, with atomic
checkpointing to durable storage and restore-on-restart. "Atomic snapshot to
S3" is modeled with a local directory standing in for a bucket: write to a
temp key, then atomically publish via os.replace, mirroring S3's own atomic
single-object PUT visibility. No live S3 is available in this sandbox.
"""
import json, os, shutil, glob
class StatefulSumOperator:
def __init__(self, checkpoint_dir):
self.checkpoint_dir = checkpoint_dir
os.makedirs(checkpoint_dir, exist_ok=True)
self.state = {}
self.last_offset = -1
self._restore_latest()
def process_event(self, offset, key, value):
if offset <= self.last_offset:
return
self.state[key] = self.state.get(key, 0) + value
self.last_offset = offset
def checkpoint(self):
checkpoint_id = self.last_offset
final_path = os.path.join(self.checkpoint_dir, f"checkpoint-{checkpoint_id:010d}.json")
temp_path = final_path + ".tmp"
payload = {"last_offset": self.last_offset, "state": self.state}
with open(temp_path, "w") as f:
json.dump(payload, f)
f.flush()
os.fsync(f.fileno())
os.replace(temp_path, final_path) # atomic on POSIX
return checkpoint_id
def _latest_checkpoint_path(self):
paths = sorted(glob.glob(os.path.join(self.checkpoint_dir, "checkpoint-*.json")))
return paths[-1] if paths else None
def _restore_latest(self):
path = self._latest_checkpoint_path()
if path is None:
return
with open(path) as f:
payload = json.load(f)
self.state = payload["state"]
self.last_offset = payload["last_offset"]
def main():
ckpt_dir = os.path.join(os.path.dirname(__file__), "s29_checkpoints")
if os.path.exists(ckpt_dir):
shutil.rmtree(ckpt_dir)
op = StatefulSumOperator(ckpt_dir)
events = [(0, "a", 5), (1, "b", 3), (2, "a", 2), (3, "c", 10), (4, "a", -1),
(5, "b", 7), (6, "a", 1), (7, "c", 4), (8, "b", -2), (9, "a", 6)]
for offset, key, value in events:
op.process_event(offset, key, value)
if offset in (4, 9):
cid = op.checkpoint()
print(f"Checkpointed at offset {offset} (checkpoint id {cid}); state so far: {op.state}")
state_before_crash = dict(op.state)
print(f"\nState before simulated crash: {state_before_crash}")
# Simulated crash: FRESH instance on the SAME checkpoint dir, no in-memory carryover.
op2 = StatefulSumOperator(ckpt_dir)
print(f"Restored state after simulated restart: {op2.state}, last_offset={op2.last_offset}")
assert op2.state == state_before_crash
assert op2.last_offset == 9
ground_truth = {}
for _, key, value in events:
ground_truth[key] = ground_truth.get(key, 0) + value
print(f"Ground truth (summed directly from all events): {ground_truth}")
assert op2.state == ground_truth
print("Assertion passed: state restored purely from disk exactly matches ground truth.")
# Atomicity proof: simulate a crash MID-checkpoint (an incomplete .tmp file exists,
# os.replace never ran), confirm restore falls back to the last GOOD checkpoint.
op3 = StatefulSumOperator(ckpt_dir)
op3.process_event(10, "a", 100)
incomplete_path = os.path.join(ckpt_dir, "checkpoint-0000000010.json.tmp")
with open(incomplete_path, "w") as f:
f.write('{"last_offset": 10, "state": {"a": ') # deliberately truncated
op4 = StatefulSumOperator(ckpt_dir)
print(f"\nAfter a simulated crash mid-checkpoint (incomplete .tmp present, never "
f"published): restored state = {op4.state}, last_offset={op4.last_offset}")
assert op4.state == ground_truth
assert op4.last_offset == 9
print("Assertion passed: the incomplete .tmp file is correctly ignored; restore")
print("falls back to the last GOOD checkpoint.")
shutil.rmtree(ckpt_dir)
if __name__ == "__main__":
main()
Output (actually executed with python3):
Checkpointed at offset 4 (checkpoint id 4); state so far: {'a': 6, 'b': 3, 'c': 10}
Checkpointed at offset 9 (checkpoint id 9); state so far: {'a': 13, 'b': 8, 'c': 14}
State before simulated crash: {'a': 13, 'b': 8, 'c': 14}
Restored state after simulated restart: {'a': 13, 'b': 8, 'c': 14}, last_offset=9
Ground truth (summed directly from all events): {'a': 13, 'b': 8, 'c': 14}
Assertion passed: state restored purely from disk exactly matches ground truth.
After a simulated crash mid-checkpoint (incomplete .tmp present, never published): restored state = {'a': 13, 'b': 8, 'c': 14}, last_offset=9
Assertion passed: the incomplete .tmp file is correctly ignored; restore
falls back to the last GOOD checkpoint.
The restored state after a simulated crash matches both the last checkpoint's recorded state AND the ground truth computed independently by summing every event directly, confirming the checkpoint mechanism captured state correctly. The atomicity test is the deliberately non-vacuous proof: a genuinely incomplete, truncated .tmp file is left on disk (simulating a crash mid-write, before os.replace ran), and restore correctly ignores it entirely, falling back to offset 9's last GOOD checkpoint rather than either crashing on the malformed JSON or silently adopting a partial state.
Trade-offs and pitfalls
- Common mistake: writing directly to the final checkpoint filename instead of a temp-file-then-rename. A crash mid-write to the final filename directly leaves a corrupted or truncated file exactly where restore expects a valid one, forcing restore to either crash or (worse) silently load malformed state; the temp-then-atomic-rename pattern above avoids this by construction, since the final filename never exists in a partial state.
- Common mistake: checkpointing state without the corresponding offset, or vice versa. Either one alone is insufficient information for a correct restore, exactly the coupling this implementation deliberately keeps as one JSON payload written in one atomic operation.
- Full-state snapshotting (this exercise's approach) does not scale indefinitely. Every checkpoint here re-writes the ENTIRE state, cheap for a handful of keys, but for state with millions of keys this becomes the dominant cost; production systems (Flink's incremental RocksDB checkpoints) checkpoint only the DELTA since the last checkpoint, once state size crosses that threshold.
- This implementation checkpoints state alone; it does not by itself give exactly-once output to a downstream sink. If this operator's sums are themselves written onward to an external system, that write needs the same idempotent, keyed-write discipline any downstream sink write does, since checkpoint/restore correctness for the OPERATOR's own state is a necessary but not sufficient condition for end-to-end correctness of everything downstream of it.
For a pipeline processing 100M events/day, propose a cost-optimized architecture using spot instances, autoscaling, and tiered storage. Include expected cost-saving techniques, risks associated with preemptible compute (spot), strategies for handling preemptions safely, and data retention tiering (hot/warm/cold) with lifecycle policies.
Sample Answer
Direct answer. A cost-optimized architecture for a large, steady event-processing workload combines spot instances for the bulk of compute (since batch/ETL work tolerates interruption well when checkpointed), autoscaling to match capacity to actual demand rather than provisioning for peak year-round, and tiered storage (hot/warm/cold) to avoid paying premium storage rates for data that is rarely accessed -- each lever targets a different part of the cost structure, and combining them compounds the savings.
Structured elaboration.
- Spot instances for compute. For a workload like daily event processing that is checkpointable and tolerant of occasional restarts, running the bulk of compute on spot instances can cut compute cost substantially versus on-demand pricing, provided standard preemption-mitigation strategies (checkpointing, a capacity buffer, redundancy across instance types/AZs) are actually implemented, not assumed.
- Autoscaling. Rather than provisioning a fixed cluster sized for peak daily volume year-round, autoscale to the actual load curve, so off-peak hours run a smaller (cheaper) cluster -- this specifically targets the WASTE of idle peak-sized capacity during non-peak periods, which is often the single largest avoidable cost in a fixed-provisioning setup.
- Tiered storage with lifecycle policies. Classify data by access recency/frequency: hot (recently processed, frequently queried) on fast, more expensive storage; warm (occasionally accessed) on a mid-tier; cold (rarely accessed, retained for compliance/history) on the cheapest archival tier. Automate the transition between tiers via lifecycle policies rather than manual intervention, since manual tiering rarely keeps up with actual access patterns.
- Risks of preemptible compute and mitigation. Spot/preemptible instances can be reclaimed with short notice; mitigate via frequent checkpointing (bounding rework), diversifying across instance types/availability zones (reducing correlated preemption risk), and maintaining a small non-spot capacity buffer for critical-path work, matching the same checkpoint-and-buffer pattern that makes spot instances safe for any preemption-tolerant batch workload.
Worked example. A pipeline processing 100 million events/day: the bulk of daily batch processing runs on spot instances checkpointed every few minutes, with a capacity buffer of on-demand instances covering roughly 15-20% of expected peak capacity to absorb preemption events without missing the processing SLA. Autoscaling shrinks the cluster to a fraction of its peak size during predictable low-traffic overnight hours (if the workload has such a pattern) rather than running peak-sized capacity around the clock. Data lifecycle policy moves processed events older than 7 days from hot storage to a warm tier, and events older than 90 days to cold archival storage, each transition automated rather than manually triggered.
Trade-offs & pitfalls. These three levers interact: an aggressively autoscaled, mostly-spot cluster needs MORE robust checkpointing than a stable, mostly-reserved one, since both scaling events and preemptions can interrupt in-flight work, and under-investing in checkpointing to save implementation time undermines the savings from both other levers when a preemption or scale-down event forces expensive rework. Cold-tier storage typically has a real RETRIEVAL cost and/or latency penalty (not just a lower storage rate) -- data tiering decisions should be validated against actual access patterns (how often is 90-day-old data genuinely queried, and how quickly must it come back) rather than assumed acceptable purely from the storage-cost side of the trade-off.
Unlock Full Question Bank
Get access to all Data Pipeline Scalability and Performance interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.