Graph
RDD

🧱RDD

NEW

Also known as: Resilient Distributed Dataset

Immutable, partitioned collections that enable parallel data processing and fault tolerance in Apache Spark.

DESCRIPTION

Resilient Distributed Datasets (RDDs) are Spark’s foundational abstraction for distributed collections. They are immutable, partitioned, and support lazy transformations and eager actions. Lineage information allows recomputation for fault tolerance instead of replication. RDDs provide fine-grained control over partitioning, caching, and low-level operations. While powerful, they require careful management of types and performance. Spark DataFrames and Datasets are recommended for most workloads, offering optimization via Catalyst and Tungsten while RDDs remain useful for custom or unstructured processing.

ALTERNATIVE DEFINITIONS

Apache Spark

Resilient Distributed Datasets (RDDs) are a fundamental data structure of Spark. An RDD is an immutable distributed collection of objects.

Stresses immutability and fundamental role in Spark.

Source

Wikipedia

A resilient distributed dataset (RDD) is a set of data elements partitioned across many computers that can be operated on in parallel.

Emphasizes partitioning and parallelism.

Source

Apache Spark Lineage MapReduce Shuffle Directed Acyclic Graph Lazy Evaluation Transformation Action

COMPETING TERMS

DataFrame Dataset

KNOWLEDGE AREAS

Data Engineering Real-time & Streaming Data Software Engineering

TARGET AUDIENCE

Data Engineer Software Developer Data Scientist

EXTERNAL SOURCES

TOP QUESTIONS

Why would I choose RDDs over DataFrames in Spark?

Use RDDs for low-level data manipulation, custom partitioning, or when schema-less or complex objects are involved. For most analytics, DataFrames offer better optimization and simplicity.

Category: Alternatives

How do RDDs achieve fault tolerance?

RDDs track lineage of transformations. On failure, Spark recomputes lost partitions from lineage rather than relying on replication, balancing resilience with storage overhead.

Category: Concepts

What is a common performance pitfall with RDDs?

Excessive shuffles from wide transformations degrade performance. Cache reused RDDs and coalesce or repartition wisely to reduce shuffle costs.

Category: Mistakes

How do RDD transformations differ from actions?

Transformations are lazy and build a lineage; actions trigger execution and return results or write outputs. This model enables optimization and fault recovery.

Category: Concepts

Can RDDs be used with Structured Streaming?

Structured Streaming is DataFrame-based. While you can convert, the recommended path is to work with DataFrames/Datasets for streaming workloads.

Category: Scope

How should I partition RDDs?

Match partitions to cluster resources and data distribution. Use hash or range partitioners for key-based operations and avoid skew from high-cardinality hotspots.

Category: Best practices

Do RDDs support schema enforcement?

No, RDDs hold arbitrary objects without schema. DataFrames provide schema and type information, enabling optimizations and SQL integration.

Category: Misunderstanding

How do I persist RDDs effectively?

Use cache or persist with appropriate storage levels. Persist only reused RDDs and unpersist promptly to manage memory pressure.

Category: Management

What is lineage in the context of RDDs?

Lineage records transformation dependencies as a DAG. It allows Spark to recompute lost partitions after failures, enabling fault tolerance without replication.

Category: Concepts