home
diamond Go Premium
Data Engineering Path  ·  PySpark

RDD Foundations & Architecture

Series Data Engineering & Distributed Systems Series
Estimated Time ~30 Mins Read
Core Objective

"Deep-dive into Resilient Distributed Datasets (RDDs) — Spark's fundamental low-level data abstraction, five internal properties, lazy DAG evaluation, and lineage-based fault tolerance."


What is an RDD?

An RDD is an immutable, partitioned collection of records operated on in parallel across a cluster of worker nodes:

  • Resilient: Self-healing via lineage graphs — lost partitions are recomputed automatically without data replication.
  • Distributed: Dataset is divided into logical partitions processed in parallel across cluster nodes.
  • Dataset: Read-only collection of typed objects (tuples, rows, key-value pairs).

The 5 Core RDD Properties

classDiagram
    class RDD {
        +List Partitions
        +List Dependencies
        +Function Compute
        +Partitioner partitioner
        +List PreferredLocations
    }
  1. Partitions List: The physical units of parallelism.
  2. Dependency List (Lineage): Tracks parent RDDs to rebuild lost partitions.
  3. Compute Function: Applies transformation logic to an iterator of partition records.
  4. Partitioner (Optional): Hashes keys across worker nodes (e.g. HashPartitioner).
  5. Preferred Locations (Optional): Enforces Data Locality by executing tasks on nodes hosting the underlying HDFS blocks.

Lazy Evaluation & Lineage Fault Recovery

Spark delays execution of Transformations (map, filter, flatMap) until an Action (collect, count, saveAsTextFile) is called. When triggered, the DAG Scheduler compiles the lineage graph into physical stages and parallel tasks.

graph LR
    Input[("HDFS File")] -->|textFile| RDD1["RDD 1 (Lines)"]
    RDD1 -->|filter| RDD2["RDD 2 (Errors)"]
    RDD2 -->|map| RDD3["RDD 3 (Messages)"]
    RDD3 -->|collect| Output["Driver Program"]

    style RDD1 fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    style RDD2 fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    style RDD3 fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;

If a worker node crashes mid-job, Spark uses the RDD's lineage graph to recompute only the missing partition on a healthy node, avoiding heavy 3x disk replication.


MapReduce vs RDD Comparison

Dimension Hadoop MapReduce Spark RDD
Intermediate Data Storage Disks (HDFS block writes between stages) Executor RAM (In-Memory Cache)
Fault Tolerance Model 3x HDFS Data Replication DAG Lineage Graph Recomputation
Iterative Algorithm Speed Disk-bound, slow Up to 100x faster
Find this content helpful? ☕ Buy me a coffee

Entity Details

Create New Item

celebration
Enjoying the free content?

Create a free account to track your progress and save your place.

Create Free Account
help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.