What is Spark, and why does it exist

A distributed engine for processing data too large for one machine, and the problem it replaced.

The problem before Spark

A single machine has a ceiling on CPU, memory, and disk I/O. Once a dataset outgrows that ceiling, processing it on one machine either fails outright or takes too long to be useful.

solved this by splitting work across many machines, but it wrote intermediate results to disk between every step. That made it reliable but slow for anything with multiple processing stages.

What Spark does differently

distributes the same way: it splits data into and runs the same computation on each partition, in parallel, across a cluster of machines.

The difference is that Spark keeps intermediate data in memory across steps whenever possible, only spilling to disk when memory runs out. That's the main reason it is faster than plain MapReduce for multi-step pipelines.

The driver and the executors

A Spark application has one , which plans the work and tracks its progress, and many , which actually run the computation on their slice of the data.

You write code against the driver's API. Spark turns that code into a plan, splits the plan into tasks, and sends those tasks to executors to run against their partitions.

Practice / self-test

1. What is the main reason Spark is typically faster than plain MapReduce?

Reveal answer

Spark keeps intermediate results in memory across processing steps instead of writing them to disk after every step, only spilling to disk when memory is insufficient.

2. What are the two kinds of processes in a running Spark application?

Reveal answer

A single driver, which plans the work and tracks progress, and many executors, which run the actual computation against their partition of the data.