DataEngPrep.tech
QuestionsPracticeAI CoachDashboardPacksBlog
ProLogin
Home/Questions/System Design/Architecture/Design a data pipeline for streaming analytics.

Design a data pipeline for streaming analytics.

System Design/Architecturehard3 min readPremium

**Section 1 — The Context (The 'Why')** Streaming analytics pipelines face the fundamental tension between low-latency ingestion and consistent aggregation at scale. The primary challenge is maintaining exactly-once or at-least-once semantics while supporting late-arriving...

🤖 Analyze Your Answer
Frequency
Low
Asked at 1 company
Category
179
questions in System Design/Architecture
Difficulty Split
15E|6M|158H
in this category
Total Bank
1,863
across 7 categories
Asked at these companies
Uber
Key Concepts Tested
joinoptimizationpartitionsparkwindow

Why This Question Matters

This hard-level System Design/Architecture question appears frequently in data engineering interviews at companies like Uber. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (join, optimization, partition) will help you answer variations of this question confidently.

How to Approach This

This is a senior-level question that tests architectural thinking. Lead with the high-level design, then drill into specifics. Discuss trade-offs explicitly - there is rarely one correct answer. Show awareness of scale, fault tolerance, and operational complexity. The expert answer includes a code example that demonstrates the implementation pattern.

Expert Answer
601 wordsIncludes code

Section 1 — The Context (The 'Why')
Streaming analytics pipelines face the fundamental tension between low-latency ingestion and consistent aggregation at scale. The primary challenge is maintaining exactly-once or at-least-once semantics while supporting late-arriving events, handling backpressure when downstream processors cannot keep pace, and avoiding data skew when hot partitions (e.g., popular products) overwhelm single workers. A naive fire-and-forget approach breaks under burst traffic: consumers fall behind, watermarks stall, and dashboards show stale or incorrect metrics.

Section 2 — The Diagram

[API/Events] --> [Kafka Cluster] --> [Flink/Spark] --> [Delta/Redis]
| | | |
v v v v
[Schema Reg] [Partitioned [State Store] [BI Dashboard]
Buffered] [Watermarks]

Section 3 — Component Logic
The event ingestion layer (API gateway, mobile SDKs) publishes raw events to Kafka. Kafka serves as a durable, partition-tolerant buffer with configurable replication factor; its partitioning strategy (e.g., by user_id or session_id) directly impacts downstream parallelism and data skew. The stream processor (Flink or Spark Structured Streaming) consumes from Kafka with exactly-once semantics via transactional commits and checkpointing. Windowed aggregation uses event-time watermarks to handle late arrivals; a TTL policy on state stores prevents unbounded memory growth. The serving layer (Delta Lake for batch access, Redis for sub-second dashboards) enables both historical querying and real-time read-through. Backpressure handling flows upstream: when Flink cannot process fast enough, Kafka consumer lag increases and producers may throttle or buffer. In production, monitor consumer lag, checkpoint success rate, and sink write latency as primary SLOs. Partitioning strategies should align with query patterns; bucketing within partitions mitigates join skew. TTL policies on raw and intermediate data control storage cost while preserving replay capability for debugging and backfill. Data skew mitigation via salting or secondary hashing prevents single partitions from becoming bottlenecks. Exactly-once semantics require transactional commits at the sink; at-least-once delivery demands idempotent write logic to avoid duplicates. Fan-out patterns allow one source topic to feed multiple downstream consumers without re-ingestion. Backpressure handling ensures that slow processors do not cause unbounded buffer growth; Kafka consumer lag is a key metric. Schema evolution should follow additive-only rules where possible to avoid breaking consumer compatibility. The CAP trade-off should be documented per component: analytics typically favors AP, while financial reconciliation requires CP. Blast radius from component failure is bounded by replication and checkpointing; design for graceful degradation during partial outages. Cost optimization: use Spot instances for batch workloads and tier cold data to lower storage classes. Dead-letter queues preserve failed records for replay rather than dropping them.

Section 4 — The Trade-offs (The 'Senior' part)

  • CAP Theorem: We choose AP (Availability + Partition Tolerance) because streaming analytics dashboards tolerate stale-by-minutes data during network partitions. Strong consistency would require synchronous replication, blocking writes and increasing latency. Eventual consistency is acceptable for operational metrics.
  • Cost vs. Performance: Managed Flink (KDA) ~$0.11/processing-hour vs self-managed Flink on EMR (~$0.05/hr + EC2) - managed wins for operational simplicity; self-managed wins for sustained 24/7 workloads at 40%+ cost savings. Redis Cluster ~$0.02/GB-hr vs DynamoDB ~$0.25/GB-mo - Redis for sub-100ms; DynamoDB for durable key-value at scale.
  • Blast Radius: If the Kafka broker fails, ISR promotes a replica within seconds; consumers rebalance. If Flink job manager fails, checkpoints enable recovery from last committed state; at-most 1 checkpoint-interval of reprocessing. Blast radius: single partition group or job; no cascading failure.
  • Section 5 — Pro-Tip

  • Pro-Move: Design for 2x peak load from day one; use windowed aggregation with allowed-lateness and side-output for severely late events. Monitor consumer lag as a primary SLO.

  • Red Flag: Ignoring consumer lag leads to stale dashboards; at-least-once without idempotent sinks produces duplicate counts in analytics.
  • This answer is partially locked

    Unlock the full expert answer with code examples and trade-offs

    Recommended

    Start AI Mock Interview

    Practice real interviews with AI feedback, track progress, and get interview-ready faster.

    • Unlimited AI mock interviews
    • Instant feedback & scoring
    • Full answers to 1,800+ questions
    • Resume analyzer & SQL playground
    Create Free Account

    Pro starts at $24/mo - cancel anytime

    Just need answers for quick revision?

    Download curated PDF interview packs

    Interview Packs
    1,800+ real interview questions sourced from 5 top companies
    AmazonGoogleDatabricksSnowflakeMeta
    This answer is in the DE Mastery Vault 2026
    1,863 questions with expert answers across 7 categories →

    Free: Top 20 SQL Interview Questions (PDF)

    Get the most asked SQL questions with expert answers. Instant download.

    No spam. Unsubscribe anytime.

    Related System Design/Architecture Questions

    hardWhat architecture are you following in your current project, and why?FreeeasyCDC During Migration - explain approaches for real-time Change Data CaptureFreehardBriefly explain the architecture of Kafka.FreehardDescribe the data pipeline architecture you've worked with.FreehardExplain the trade-offs between batch and real-time data processing. Provide examples of when each is appropriate.Free

    Want to know if YOUR answer is good enough?

    Paste your answer and get instant AI feedback with a FAANG-level improved version.

    Analyze My Answer — Free

    According to DataEngPrep.tech, this is one of the most frequently asked System Design/Architecture interview questions, reported at 1 company. DataEngPrep.tech maintains a curated database of 1,863+ real data engineering interview questions across 7 categories, verified by industry professionals.

    ← Back to all questionsMore System Design/Architecture questions →