DISTRIBUTED COMPUTEPySpark

RDDs: The Core Abstraction

Distributed data processing with Spark — pick a topic on the left and its full breakdown loads here: the execution model, worked jobs and diagrams, performance and shuffle behavior, and the habits that keep Spark jobs fast, correct, and affordable.

18 min readTopics chapter readerLevel · Foundations
01 · Orientation

What You'll Master Here

An RDD is a single logical collection cut into partitions, each living on a worker. It remembers how it was built (its lineage), so any lost partition can be recomputed instead of restored from a backup.

4 min · Topic 1 of 6

Underneath every DataFrame, every Spark SQL query, and every streaming job sits one foundation: the RDD, the Resilient Distributed Dataset. You will rarely write RDD code today, but understanding RDDs is what makes partitions, lineage, and fault tolerance click, and those concepts power everything above them.

This chapter explains what an RDD actually is (a partitioned, immutable collection spread across the cluster), how Spark recovers from machine failure for free using lineage, and why we almost always prefer DataFrames now, while still standing on RDDs underneath.

We keep it concrete with a tiny RDD example you can run, plus diagrams of how an RDD is partitioned and how a lost partition is recomputed.

Core mental model

An RDD is a single logical collection cut into partitions, each living on a worker. It remembers how it was built (its lineage), so any lost partition can be recomputed instead of restored from a backup.

Why it matters

Partitions, lineage, and fault tolerance are RDD ideas that resurface in every later chapter and many interviews ("how does Spark recover from a failed node?"). Learn them here once and the rest of Spark rests on solid ground.

RDD
Resilient Distributed Dataset: an immutable, partitioned collection processed in parallel.
partition
One slice of an RDD; each is processed by one task on one core.
lineage
The recorded chain of transformations that built an RDD; used to recompute lost data.
immutable
RDDs never change in place; a transformation creates a new RDD.
Common mistake

Reaching for RDDs for everyday data work. You lose Catalyst optimization and write more code; prefer DataFrames unless you truly need low-level control.

Better habit

Think of any dataset as "partitions across the cluster", that is the RDD view.

Explain fault tolerance via lineage (recompute), not backups.

Default to DataFrames; treat RDDs as the foundation, not the daily tool.

The big idea

An RDD = partitions + lineage. Partitions give parallelism; lineage gives fault tolerance. DataFrames add a schema and an optimizer on top, but inherit both.

Remember this

An RDD is an immutable, partitioned, fault-tolerant collection. Partitions enable parallelism; lineage enables recompute-on-failure. DataFrames are built on this foundation.

Practice2 prompts
  1. Define an RDD in one sentence using "partitions" and "lineage".
  2. Why do we prefer DataFrames day to day if RDDs are the foundation?