Layering a Big-Data Analytics Stack: Lake, Engine, and Serving Tier
System DesignModel answerLast updated
Decide how to combine HDFS, Spark, Hive and SQL Server into a pipeline for 500 TB of logs, analyst SQL, fast executive dashboards and strict governance, and justify what to leave out.
Scenario
A fast-growing company is building a new analytics platform and you are asked to recommend the technology stack. The platform must satisfy four needs:
- Hold roughly 500 TB of semi-structured log data, refreshed by periodic batch ETL jobs.
- Let analysts run ad-hoc SQL over structured, cleaned data.
- Power low-latency dashboards for executive reporting.
- Enforce strict governance, including schema enforcement.
Candidate technologies
- Apache Hive
- Apache Spark
- Hadoop (HDFS)
- Microsoft SQL Server
What to deliver
- Compare the four technologies, saying which layer each one belongs to (storage, compute, serving) and where each is strong or weak for the needs above.
- Propose an end-to-end pipeline that combines them.
- Explain which tools you would deliberately keep out of particular layers, and why.
- State your assumptions about scale, users and freshness, and mention the main trade-offs and risks of your design.
Aim for a structured answer of the kind you would give in a screening conversation: clear and layered, with a few concrete numbers.
Hints
Hint 1
Start by labelling each tool with the layer it really occupies. One of them is purely storage, one is purely a compute engine, one is a SQL layer plus a metadata catalog, and one bundles everything together.
Hint 2
No single listed tool can handle both 500 TB of raw logs and sub-second dashboards for many concurrent users. Think about a pipeline with a heavy lake tier and a small, pre-aggregated serving tier.
Hint 3
Back up your choices with numbers: replication overhead, columnar compression ratio, daily ingest volume, and the size of a dashboard mart compared with the raw data. Then say where schema is enforced (on read vs on write).
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
This is a fundamentals question disguised as a design question. The strongest answer does not crown one winner. It classifies each tool by layer, maps each requirement to the layer that should satisfy it, and explains the exclusions.
Assumptions
- Volume: 500 TB logical. With 3x HDFS replication that is about 1.5 PB of raw disk. Columnar formats (ORC/Parquet) typically compress logs 5-10x, so curated data is roughly 50-100 TB.
- Ingest: batch, hourly or daily, around 1-2 TB/day.
- Users: tens of analysts tolerating seconds to minutes; dozens of executives expecting 1-2 second dashboard loads with concurrent refreshes.
- Governance: enforced schemas, access control, lineage, auditability.
Classifying the tools
| Tool | Layer | Good at | Weak for this problem |
|---|---|---|---|
| HDFS | Storage | Cheap, scalable, high-throughput sequential reads; holds semi-structured files | No query engine, no indexes, small-files pressure on the NameNode |
| Spark | Compute | Distributed ETL, parsing JSON, complex joins, Spark SQL | Not storage; startup/scheduling overhead; poor for high-concurrency sub-second serving |
| Hive | SQL engine + metastore | SQL over files, partitioning, central schema catalog, ACID ORC tables, integration with policy/lineage tools | Seconds-to-minutes latency even with Tez/LLAP; schema-on-read by default |
| SQL Server | RDBMS (all layers) | Schema-on-write, constraints, row-level security, columnstore aggregates, mature BI connectors | Scale-up; 500 TB of raw logs is impractical and costly; weak at parsing raw logs at scale |
Proposed pipeline
Log producers
-> HDFS raw zone (JSON/Avro, partitioned by date/hour) [storage]
-> Spark batch ETL: parse, validate, dedupe, flatten [compute]
-> HDFS curated zone (ORC/Parquet) registered in Hive metastore [storage + catalog]
-> Analysts: Hive (Tez/LLAP) or Spark SQL [ad-hoc query]
-> Spark aggregation jobs -> SQL Server data mart [serving]
-> BI dashboards read from SQL Server
Requirement by requirement
- 500 TB of logs with batch ETL. HDFS holds the data and Spark transforms it. Keep the raw zone immutable so any job can be replayed. Write output as 128 MB-1 GB files to avoid the small-files problem.
- Ad-hoc SQL. Hive tables over curated columnar files. Partition pruning and predicate pushdown keep scans cheap. Spark SQL can share the same metastore, so analysts see one schema.
- Fast executive dashboards. Serve from a small pre-aggregated star schema in SQL Server (hundreds of GB to ~1 TB) with clustered columnstore indexes. Dashboards touch gigabytes, not terabytes, so responses are sub-second to a few seconds even with many concurrent users.
- Governance. Two enforcement points:
- Lake: the Hive metastore is the source of truth for schemas; Spark validates against it and quarantines bad records; transactional ORC tables handle updates and deletes (for example privacy deletions); a policy engine such as Ranger provides column/row access control and a catalog tool such as Atlas provides lineage.
- Serving: SQL Server's schema-on-write, constraints, foreign keys and row-level security give the strictest guarantees on executive numbers.
Why exclude tools from certain layers
- Storage: SQL Server is excluded for raw logs. Scaling a licensed scale-up RDBMS to 500 TB is very expensive, and it would force rigid schemas onto messy, evolving data. Spark and Hive do not store data themselves.
- Compute/ETL: Spark is preferred over Hive for heavy transformation because of in-memory multi-stage execution, nested-JSON handling and UDF flexibility. Hive is fine for simple SQL-only transforms. SQL Server tooling cannot scale out to terabytes per day of parsing. HDFS has no compute.
- Serving: Hive and Spark are excluded for dashboards because of job startup overhead and limited concurrency; 50 executives refreshing at once would queue and compete with ETL. HDFS cannot answer queries. SQL Server is chosen, with the caveat that it works only because it serves a small pre-aggregated mart rather than raw scans.
Trade-offs and risks
- Two copies of the truth. Lake and mart can drift. Mitigate with one Spark job per mart table, reconciliation checks (row counts, sums) and a visible freshness timestamp.
- Freshness vs latency. The mart is only as fresh as the last batch, acceptable for executive reporting but not for operational alerting.
- Operational burden. Running HDFS (NameNode HA, capacity planning, rebalancing) is heavy. Many teams now use object storage with a table format such as Iceberg or Delta. Mention it as an evolution, but keep the core answer within the listed tools.
- Schema-on-read vs schema-on-write. Schema-on-read gives flexibility for logs; schema-on-write gives trust for executive metrics. The design intentionally uses both.
Common mistakes
- Treating Hive, Spark and HDFS as interchangeable "big data tools".
- Saying Hive is a database that stores data itself, when it is a SQL layer and metastore over files.
- Proposing Spark or Hive directly behind dashboards.
- Putting 500 TB of raw logs in SQL Server.
- Giving no numbers (replication, compression, mart size) and ignoring the small-files problem.
Follow-up angles
- Changing log formats: keep the raw payload untouched, evolve curated schemas with backward-compatible changes, and quarantine records that fail validation.
- Lower dashboard latency or fresher data: add incremental micro-batch loads into the mart, or a dedicated OLAP serving store.
- Cost control: tiered storage, erasure coding in place of 3x replication for cold data, and lifecycle policies on the raw zone.