Essential cookies keep authentication working. With your permission, we also use analytics cookies to understand and improve the product. Read our Privacy Policy

DataEngPrep.tech
QuestionsPracticeAI CoachDashboardPricingBlog
ProLogin
Home/Questions/System Design/Architecture/How would you design an architecture that supports both batch and real-time analytics for sales data?

How would you design an architecture that supports both batch and real-time analytics for sales data?

System Design/Architecturehard2.5 min read

Reviewed by Aditya Kumar · Last reviewed 2026-03-25

**Section 1 — The Context (The 'Why')** The primary challenge in 'How would you design an architecture that supports both batch and real-time analytics for sales data?' centers on designing for production scale, correctness guarantees, and operational resilience. A naive or...

🤖 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
Adidas
Key Concepts Tested
joinpartitionsparkwindow

Why This Question Matters

This hard-level System Design/Architecture question appears frequently in data engineering interviews at companies like Adidas. While less common, it tests deeper understanding that distinguishes strong candidates. Mastering the underlying concepts (join, partition, spark) 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
491 wordsIncludes code

Section 1 — The Context (The 'Why')
The primary challenge in 'How would you design an architecture that supports both batch and real-time analytics for sales data?' centers on designing for production scale, correctness guarantees, and operational resilience. A naive or underspecified design fails under load: single points of failure cascade, non-idempotent operations cause duplicates on retry, and lack of observability blocks root-cause analysis. At enterprise scale, failure modes multiply—what works for small batches breaks when volume grows 10x. The diagram above shows the key components; each must be chosen for its role in ensuring backpressure handling (protecting sources when consumers lag), idempotency (safe retries), and partitioning strategies (horizontal scale). Senior architects prioritize explicit trade-offs: CAP choices, cost vs. latency, and blast radius containment.

Section 2 — The Diagram

[Sales Events]
|
+->[Stream: Flink]-->[Redis/BQ]
|
+->[Batch: S3]-->[Spark]-->[DW]
|
v
[Reconcile: Batch corrects stream]

Section 3 — Component Logic
Each component in the diagram above serves a critical role. The architecture must apply backpressure handling to prevent overwhelming sources when consumers lag—rate limits and flow control propagate upstream so producers slow rather than overflow buffers. Idempotency at the sink ensures safe retries without duplicates; use deterministic keys (e.g., hash of business key + timestamp) so replay produces the same result. Partitioning strategies (by date, region, or business key) enable parallel processing and cost-efficient query pruning; undersizing partitions causes hot spots and data skew. For streaming, exactly-once semantics require checkpointing plus transactional sinks (Kafka + Delta MERGE); without both, duplicates or gaps occur. Fan-out patterns allow one source to feed multiple consumers independently; each consumer can scale and fail without blocking others. TTL policies control retention and lifecycle costs—raw zones kept short for replay, curated zones longer. Data skew mitigation (salting hot keys, broadcast joins for small dimensions) prevents stragglers from dominating runtime; one skewed partition can 10x job duration. For this specific design: Exactly-once in both paths. Reconciliation batch. Idempotency for merge. Implementation choices depend on throughput, latency SLA, and compliance: high-throughput batch favors Spark/EMR; sub-second streaming needs Flink; warehouse loads prefer dbt or merge-based loads. Monitor partition lag, validation failure rates, and sink latency; alert on drift. When designing from scratch, prefer managed services (Kinesis, Glue, Athena) for faster iteration; migrate to self-managed (Kafka, EMR) when cost or control dictates. Always document assumptions (e.g., max late arrival, retention window) so future changes are informed. Test failure injection (kill workers, delay sources) to validate recovery behavior before production. This discipline separates production-grade systems from proof-of-concepts.

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

  • CAP Theorem: Consistency via reconciliation: batch is source of truth; stream for latency. Eventually consistent.
  • Cost vs. Performance: Lambda: stream path 2x batch. Same logic: reduce dual maintenance. Nightly reconcile: EMR Spot.
  • Blast Radius: Stream fail: batch fills gap. Divergence: reconcile job fixes. Adidas: real-time dashboards + monthly reports.
  • Section 5 — Pro-Tip

  • Pro-Move: Shared logic; reconcile nightly.

  • Red Flag: Divergent logic—inconsistency.
  • ⚡
    Pro Tip

    Pro-Move: Shared logic; reconcile nightly. Red Flag: Divergent logic—inconsistency.

    Want all answers as a PDF for offline study?
    Seven focused volumes with 750+ in-depth answers — Answer Vault →

    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

    Level up your prep

    Recommended
    Educative
    Educative Unlimited

    800+ hands-on courses — Grokking System Design, Coding Patterns, and AI mock interviews for your DE loop.

    Start learning →

    Some links below are affiliate links. If you buy through them we may earn a small commission at no extra cost to you — it helps keep DataEngPrep 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 an editor-reviewed database of 1,863 data engineering interview questions across 7 categories.

    ← Back to all questionsMore System Design/Architecture questions →
    Categories
    All QuestionsSQLSpark / Big DataPython / CodingSystem DesignCloud / ToolsBehavioral
    By Company
    AmazonGoogleDatabricksSnowflakeAWSAzureMicrosoftNetflixUberTCS
    Interview Guides
    All GuidesTop SQL QuestionsTop Spark QuestionsPySpark QuestionsTop Python QuestionsTop System DesignKafka QuestionsAirflow QuestionsSQL Window FunctionsETL QuestionsData Modeling
    Products
    AI Interview CoachAnswer AnalyzerSQL PlaygroundResume AnalyzerAnswer Vault PDFsPricing
    Company
    About & Editorial PolicyContact UsAI DisclosureDisclaimerTerms of ServicePrivacy Policy
    © 2026 DataEngPrep.tech. All rights reserved.
    AboutBlogContactDisclaimer