The Clock That Runs Two Ways

A hard Pipeline Design interview practice problem on DataDriven. Design the pipeline on the canvas: sources, transforms, storage and checks, then get feedback on it.

Domain
Pipeline Design
Difficulty
hard
Seniority
L5
Asked in
dbt Labs

Problem

Orders arrive on two clocks: a nightly extract from an on-premises transactional database and a real-time event stream from microservices, each under its own scheduler today. Both paths must land in one landing zone under one orchestration layer, with one SLA dashboard and one failure alert covering both.

Nightly batch and live events. One dashboard.

Business requirements

Worked solution and explanation

This is one control plane over two clocks, dressed up as a data lake project. Anyone can draw a batch path and a stream path into a lake. What separates candidates is whether one scheduler owns the deadline for both, and whether the lake has a deterministic rule when the same order shows up twice. Skip that and the on-prem network drops on a Sunday, the batch dies quietly, and finance opens an empty landing zone at 6am UTC on Monday while streaming lag builds on a dashboard nobody shares.

Walk the requirements

Step 1: Put one orchestrator over both paths

Airflow schedules the nightly extract and supervises the streaming consumer. It is the only node that knows both clocks, so it is the only place a 'batch at risk before 6am UTC' alert or a 'lag past tolerance' alert can be raised. Separate schedulers cannot give leadership one view.

Step 2: Give the SLA dashboard its own stage

The orchestrator feeds a Grafana SLA dashboard that shows batch lateness next to streaming lag. That is the one shared view the stakeholders asked for. Alerts fire from the orchestrator hours before the deadline, so on-call recovers the monthly network drop overnight instead of finding it at 6am.

Step 3: Merge into one landing zone with streaming winning

Both paths feed one merge step, named for its rule: streaming wins merge. It upserts on order_id and ranks the streaming record above the batch record, so each order resolves to one outcome whichever path arrived first. The landing zone it writes is where finance reads at 6am UTC.

The orchestrator supervises both clocks and feeds the SLA dashboard. Both paths meet in one merge where the streaming record wins, landing in the zone finance reads.
  • on prem db (source, PostgreSQL)
  • microservices (source, Kafka)
  • batch loader (transform, Spark); freshness: < 24h
  • streaming consumer (transform, Flink); freshness: real-time
  • orchestrator (transform, Airflow); on error: alert; alerting: Batch at risk vs 6am UTC or streaming lag past tolerance
  • streaming wins merge (transform, Spark); idempotency: upsert
  • landing zone (storage, Delta Lake)
  • SLA dashboard (consumer, Grafana)
  • finance reporting (consumer, Metabase)
  • on prem db -> batch loader
  • microservices -> streaming consumer
  • orchestrator -> batch loader
  • orchestrator -> streaming consumer
  • batch loader -> streaming wins merge
  • streaming consumer -> streaming wins merge
  • streaming wins merge -> landing zone
  • landing zone -> finance reporting
  • orchestrator -> SLA dashboard
  • Source Layer: on prem db, microservices
  • Ingestion Layer: batch loader, streaming consumer
  • Processing Layer: orchestrator, streaming wins merge
  • Storage Layer: landing zone
  • Serving Layer: SLA dashboard, finance reporting

Common follow-up questions