Welcome to your next lesson in the "Scalable Data Processing and Platforms" module.
In our last lesson, we explored how columnar storage formats like Parquet are the essential foundation for high-performance analytics. We saw how they optimize I/O, compression, and CPU usage. Today, we move up a level from the file format to the systems that manage and serve this data at scale.
This lesson directly addresses the learning outcome: Contrast the architectures of a data lake and a data warehouse, including the separation of storage and compute. Understanding these macro-level architectures is fundamental for any system design interview at an elite tech company, as it forms the basis of all large-scale data and ML platforms.
We'll dissect this topic into five interconnected concepts, starting with the classic architectures and moving to the modern paradigm that powers companies like Google and Snowflake.
- The Data Warehouse: The Curated Library for Business Intelligence
- The Data Lake: The Raw Repository for Exploratory Analysis
- Architectural Contrast: ETL vs. ELT & Schema-on-Write vs. Schema-on-Read
- The Game Changer: Separation of Storage and Compute
- The Synthesis: The Data Lakehouse
1. The Data Warehouse: The Curated Library for Business Intelligence (Easy)
-
Technical Explanation:
A Data Warehouse (DWH) is a central repository of integrated data from one or more disparate sources. Its primary purpose is to support Business Intelligence (BI), reporting, and SQL-based analytics. The key characteristics are:- Structured Data: It stores cleaned, transformed, and structured data.
- Schema-on-Write: A predefined schema (like a SQL table definition) must be created before data can be loaded. This ensures data quality and consistency.
- OLAP Optimized: It is designed for Online Analytical Processing (OLAP), which involves complex queries over large historical datasets.
- ETL Process: Data is populated using an Extract, Transform, Load (ETL) process. You extract data from source systems (e.g., a transactional database), transform it into the target schema (e.g., cleaning, joining, aggregating), and then load it into the warehouse.
-
Metaphor for a 5-Year-Old:
A data warehouse is like a pristine, well-organized public library. The librarians (data engineers) carefully select books (data), translate them into a common language, and put them on specific, labeled shelves (the schema). When you visit, you know you'll get a reliable, clean, and easy-to-find answer to your question. -
Python Code Snippet (Conceptual "Transform" Step):
This snippet shows the "T" in ETL. Raw, messy data is transformed into a clean, structured format ready for loading into a warehouse.# Raw data records extracted from source systems raw_order_data = {'order_id': 'o-9981', 'user_email': ' TEST@EXAMPLE.com ', 'sale_value': '55.99 USD'} raw_user_data = {'email': 'test@example.com', 'country_code': 'US'} def transform_for_warehouse(raw_order, raw_user): """Transforms raw data into a clean, structured schema.""" # Clean, standardize, and join data transformed_record = { 'order_id': int(raw_order['order_id'].split('-')[1]), 'user_email': raw_order['user_email'].strip().lower(), 'sale_usd': float(raw_order['sale_value'].split(' ')[0]), 'user_country': raw_user['country_code'] } return transformed_record # The data is now clean and structured, ready to be LOADED into the warehouse. clean_record = transform_for_warehouse(raw_order_data, raw_user_data) print("Transformed Record (ready for DWH):") print(clean_record) # Expected output: {'order_id': 9981, 'user_email': 'test@example.com', 'sale_usd': 55.99, 'user_country': 'US'}
2. The Data Lake: The Raw Repository for Exploratory Analysis (Easy)
-
Technical Explanation:
A Data Lake is a centralized repository that allows you to store all your structured, semi-structured (JSON, XML, logs), and unstructured (images, audio, documents) data at any scale.- Raw Data: Data is stored in its native, raw format. No structure is imposed on it when it's stored.
- Schema-on-Read: You apply a schema or interpretation to the data when you query it, not when you write it.
- Flexibility: Ideal for data science, machine learning, and exploratory analysis where the questions are not known in advance.
- ELT Process: The typical data flow is Extract, Load, Transform (ELT). You extract data from the source and load it directly into the lake. Transformations happen later, on-demand, by the users querying the data.
- Storage: Built on cheap, scalable object storage like Amazon S3 or Google Cloud Storage.
-
Metaphor for a 5-Year-Old:
A data lake is like a giant storage unit or a real lake. You can dump anything into it: old toys, furniture, photos, notes, etc. It's very cheap and easy to put things in. When you need something, you have to go in, find it, and figure out what it is and how to use it. It gives you the flexibility to use the raw materials for anything you can imagine later on. -
Python Code Snippet (Conceptual "Load" Step):
This snippet shows the "L" in ELT. We just dump the raw data into our "lake" (a local file, in this case) without any pre-processing.import json import os # Raw, semi-structured data from an application log stream raw_log_event = { "timestamp": "2023-10-27T10:00:05Z", "level": "INFO", "service": "recommendation-engine", "details": { "user_id": "u-123", "items_recommended": [7, 45, 201], "model_version": "v3.1" } } # Simulate loading directly into a data lake (like saving to an S3 bucket) file_path = "data_lake/logs.json" os.makedirs(os.path.dirname(file_path), exist_ok=True) with open(file_path, "w") as f: # We just LOAD the raw JSON string. No transformation. json.dump(raw_log_event, f) print(f"Raw log event loaded into '{file_path}'") # The data scientist can now read this raw file and apply a schema later. os.remove(file_path) os.rmdir("data_lake")
3. Architectural Contrast: ETL vs. ELT & Schema-on-Write vs. Schema-on-Read (Medium)
The fundamental differences between these two architectures stem from when you enforce structure and perform transformations.
Data Warehouse vs Data Lake vs Data Lakehouse | ETL, OLAP vs OLTP
To see a clear, side-by-side comparison, let's watch this video from codebasics. It explains the core concepts and then contrasts the two architectures effectively.
Please watch the following sections: Data Warehouse & ETL (04:41 - 06:58): To solidify your understanding of the warehouse concept. Data Lake (10:26 - 13:39): To understand the data lake's role as a repository for raw data. Summary (13:39 - 15:33): Focus on the summary table comparing the two on data type, cost, and performance.
Here's a summary of the key trade-offs, which is crucial for system design interviews:
| Feature | Data Warehouse | Data Lake |
|---|---|---|
| Data | Structured, processed | Raw, all types (structured, semi-structured, unstructured) |
| Schema | Schema-on-Write (defined before loading) | Schema-on-Read (applied during query) |
| Process | ETL (Extract, Transform, Load) | ELT (Extract, Load, Transform) |
| Primary Users | Business Analysts, Executives | Data Scientists, ML Engineers, Data Analysts |
| Use Case | BI Reporting, Dashboards, SQL Analytics | ML, AI, Exploratory Analysis, Big Data Processing |
| Performance | Very fast for repetitive, known queries | Can be slower; performance depends on the query tool |
| Flexibility | Low; schema changes are difficult and expensive | High; easily accommodates new data sources and types |
| Risk | Data might be discarded if it doesn't fit the schema | Can become a "data swamp" if ungoverned |
- Real-world Example: A large retailer like Amazon would use both.
- Data Warehouse: To power a dashboard showing the CEO the total sales-per-category for the previous day. The query is predictable, and the data must be 100% clean and reliable.
- Data Lake: To store all user clickstream data, product image files, and server logs. A data science team would use this raw data to train a new product recommendation model, a task that is experimental and requires access to the original, untransformed data.
4. The Game Changer: Separation of Storage and Compute (Hard)
This is the most significant architectural evolution in the data space in the last decade.
-
Traditional Architecture (Coupled):
In older data warehouses (and Hadoop systems), compute resources (CPU, memory) were tightly coupled with storage (disks) on the same physical nodes. To scale, you had to add more nodes, which scaled both compute and storage together.Problems with this model:
- Inflexible Scaling: What if you need lots of compute for a short time (e.g., a complex query) but don't need more storage? You still have to pay for the storage on the new nodes.
- Concurrency Issues: One team running a massive ETL job could consume all the resources on the cluster, slowing down queries from the BI team.
- High Cost: You pay for compute resources even when they are idle.
-
Modern Architecture (Decoupled / Disaggregated):
Modern cloud data platforms like Snowflake, Google BigQuery, and modern Amazon Redshift separate storage and compute.- Storage Layer: A single, centralized repository for data, typically built on a highly scalable, durable, and cost-effective cloud object store (like Amazon S3). This is the single source of truth.
- Compute Layer: One or more independent, elastic clusters of virtual machines that are spun up to execute queries. These clusters read data from the shared storage layer, perform the computations, and then can be shut down or resized.

To understand the immense power and rationale behind this shift, the original Snowflake paper is the best primary source.
The Snowflake Elastic Data Warehouse
The Snowflake paper is a seminal work in this field. It clearly articulates why the traditional shared-nothing architecture is a poor fit for the cloud and why separating storage and compute is essential.
Read Section 2, 'STORAGE VERSUS COMPUTE' (it's short, just over half a page). Focus on the three problems it identifies with tightly coupled architectures: 'Heterogeneous Workload', 'Membership Changes', and 'Online Upgrade'. This section perfectly explains the 'why' behind this architectural revolution.
- Google's Implementation (BigQuery):
Google's BigQuery is another prime example of this architecture.

The key benefits of this decoupled model are:
- Elasticity & Cost-Effectiveness: Scale compute up for heavy workloads and down to zero for idle periods, paying only for what you use. Storage costs are independent and low.
- Workload Isolation: The data science team can use a massive compute cluster for model training, while the BI team uses a small, steady cluster for dashboards. They both access the same data but do not impact each other's performance.
- Data Sharing & Simplicity: Data doesn't need to be copied for different teams. Everyone works off the same single source of truth.
5. The Synthesis: The Data Lakehouse (Harder)
-
Technical Explanation:
The Data Lakehouse is a new, hybrid architecture that aims to combine the benefits of both data warehouses and data lakes. It implements data warehouse features like ACID transactions, data versioning (time travel), and schema enforcement directly on top of the low-cost, open-format storage of a data lake.Technologies like Databricks Delta Lake, Apache Iceberg, and Apache Hudi are key enablers. They are essentially a transactional metadata layer that sits on top of Parquet files in your data lake (e.g., on S3).
-
Metaphor for a 5-Year-Old:
You still have your giant, cheap storage unit (the data lake). But now, you've installed a super-smart digital inventory system (the Lakehouse layer). This system tracks every single item, knows who put it there and when, and prevents two people from trying to take the same item at once (ACID transactions). It gives you the reliability and organization of a library but with the low cost and flexibility of your storage unit.
Data Warehouse vs Data Lake vs Data Lakehouse | ETL, OLAP vs OLTP
Let's conclude with a brief introduction to this emerging paradigm from the codebasics video.
Watch the final clip on the Data Lakehouse (15:33 - 16:11). This will connect the concepts we've discussed and introduce the modern solution.
The Data Lakehouse architecture allows you to run traditional BI queries and advanced AI/ML workloads on the same repository, eliminating data silos and redundant copies.
Test your understanding! (Interview-Style Question)
You are the first data platform engineer at a fast-growing gaming startup. They have:
- A transactional PostgreSQL database for player accounts and in-game purchases.
- Real-time event streams (JSON data) from game clients detailing every player action (e.g., move, jump, item used).
The CEO wants a daily dashboard showing revenue and player retention. The game design team wants to analyze raw player behavior to balance the game and design new features.
Propose a high-level data architecture. Should you use a data warehouse, a data lake, or both/a hybrid? Justify your decision and explicitly describe how the separation of storage and compute would be leveraged in your design.
Show answer
I would propose a hybrid architecture based on the Data Lakehouse paradigm, which leverages a central data lake with a decoupled storage and compute model. This approach satisfies both use cases efficiently and is highly scalable.
Proposed Architecture:
-
Storage Layer (The Data Lake):
- I would use a cloud object store like Amazon S3 as the single source of truth for all data.
- ELT Ingestion:
- A batch pipeline would run nightly to Extract data from the PostgreSQL database (player accounts, purchases) and Load it as Parquet files into a "raw" zone in S3.
- A streaming pipeline (e.g., using Kafka and Spark Streaming) would consume the real-time JSON game events and Load them directly into the same "raw" zone in S3, also as Parquet.
- Lakehouse Layer: I would use a format like Apache Iceberg or Delta Lake on top of these Parquet files. This provides an essential transactional layer for reliability.
-
Compute Layer (Separated & Elastic):
- For the CEO's Dashboard (BI/DWH Use Case):
- A scheduled daily job running on a dedicated Spark or SQL engine cluster would read the raw purchase and player data from the lake.
- It would Transform this data—cleaning, aggregating revenue, calculating retention metrics—and write the results back to the lake as a clean, aggregated "analytics" table.
- A BI tool (like Tableau or PowerBI) would query these small, pre-aggregated tables using a small, persistent SQL warehouse compute cluster. This ensures fast, reliable dashboard loads.
- For the Game Design Team (Data Science/Lake Use Case):
- The designers can directly query the massive, raw player event logs in the lake using their own powerful, on-demand Spark or Python (e.g., Dask) cluster. They can spin up a large cluster for a few hours to analyze terabytes of data and then shut it down, minimizing cost.
- For the CEO's Dashboard (BI/DWH Use Case):
Leveraging Separation of Storage and Compute:
This decoupled design is critical:
- Workload Isolation: The game design team's heavy, exploratory queries will not slow down the CEO's daily dashboard, because they are using separate, isolated compute clusters.
- Cost Efficiency: We are not paying for a massive, always-on cluster. The game design team's compute is ephemeral, and the BI team's compute is sized specifically for its needs. The underlying S3 storage is extremely cheap.
- Flexibility: As the company grows, we can add new data sources (e.g., marketing data, social media sentiment) to the lake without redesigning the entire system. New teams can spin up their own compute clusters to serve new use cases (e.g., an ML team building a churn prediction model) on the exact same data.
By using a Data Lakehouse architecture with separated storage and compute, we avoid creating data silos, provide a single source of truth, and build a flexible, cost-effective platform that serves both BI and data science needs from day one.
Conclusion
You've now seen the evolution of large-scale data architectures. We've moved from rigid, structured data warehouses to flexible, all-encompassing data lakes. The modern synthesis of these ideas is powered by a revolutionary architectural principle.
Key Takeaways:
- Data Warehouse (DWH): Schema-on-write (ETL), optimized for structured data and BI. High performance for known queries.
- Data Lake (DL): Schema-on-read (ELT), built for raw, multi-format data and exploratory analysis/ML. High flexibility.
- Separation of Storage and Compute: This is the key enabler for modern cloud data platforms. It provides elasticity, cost-efficiency, and workload isolation by decoupling cheap, centralized storage from ephemeral, purpose-sized compute clusters.
- Data Lakehouse: The emerging standard that brings DWH reliability (ACID, schema enforcement) to the open, low-cost environment of a data lake, creating a unified platform for nearly all data workloads.
Next Lesson Preview
We've discussed the "what" and "why" of these high-level architectures. Next, we'll focus on the "how." How do we actually move data from source systems into these lakes and warehouses? In our next lesson, you will learn to Design a high-level ETL/ELT pipeline, choosing between batch, streaming, and hybrid models.