The big data toolbox: HDFS to store, YARN to schedule, MapReduce and Spark to compute.
Hadoop and Spark are the two names you meet first in big data. Hadoop is a toolbox: HDFS to store files, YARN to share the machines, and MapReduce to compute. Spark is a faster compute engine that keeps data in memory between steps.
One machine cannot hold or scan a few terabytes quickly. The big data answer is to split the data across many cheap machines and to send the code to the data, instead of dragging the data to the code. Apache Hadoop (2006) packaged this idea. It has three layers that work together.
Spark (2014 as a top-level project) came from a simple complaint: MapReduce writes to disk after every step, which makes chains of steps and repeated passes slow. Spark describes your whole job first, as a graph of steps, and then runs it. Between steps it keeps data in memory where it can.
The key ideas of Spark's model: you build a dataset by chaining transformations (filter, map, join). These are lazy: nothing runs. Only an action (count, write, show) triggers the work. Spark then turns the chain into a DAG, cuts it into stages at every shuffle, and sends the tasks to executors on the cluster.
| Piece | Job | Remember |
|---|---|---|
| HDFS | Stores big files as replicated blocks. NameNode keeps the map, DataNodes keep the blocks. | Details on the Distributed File Systems page |
| YARN | Gives containers (CPU and memory) to applications. ResourceManager plus a NodeManager on each machine. | Spark can also run on Kubernetes or standalone |
| MapReduce | Map, shuffle, reduce, with disk between jobs. | Details on the MapReduce page |
| Hive | Writes SQL and turns it into jobs over files. The metastore keeps table definitions. | Now often runs on Tez or Spark |
| Spark core | Driver plans the job. Executors run tasks and hold cached data. | The compute engine |
| Spark SQL / DataFrames | Tables with columns. An optimizer (Catalyst) picks a good plan. | Prefer this over raw RDDs |
| Structured Streaming | Runs the same query on small batches of new data again and again. | See Streaming Engines |
| Kind | Examples | Data movement | Cost |
|---|---|---|---|
| Narrow | filter, map, select, union | Each output partition needs one input partition. No shuffle. | Cheap, pipelined inside one stage |
| Wide | groupBy, join, distinct, repartition, sort | Rows with the same key must meet. Data is shuffled between machines. | Expensive: disk, network, a new stage |
The time units are made up to show the shape of the cost (disk and network are slow, memory is fast). They are not benchmarks. Real speed depends on data size, cluster, caching and the job. The white outline marks the shuffle: in Spark it splits the job into two stages.
spark.read.text(path).groupBy("word").count().write.parquet(out). Nothing runs until the write. The group by is the shuffle.| Term | Meaning in easy words |
|---|---|
| HDFS | Hadoop Distributed File System. Big files split into replicated blocks |
| YARN | Yet Another Resource Negotiator. Shares cluster CPU and memory between jobs |
| Driver | The Spark process that plans the job and coordinates the work |
| Executor | A Spark process on a worker that runs tasks and holds cached data |
| RDD | Resilient Distributed Dataset. The low-level Spark collection, rebuilt from its recipe if lost |
| DataFrame | A Spark table with named columns, planned by an optimiser |
| Transformation | A lazy step such as filter or join. Nothing runs yet |
| Action | A step that runs the job and returns or saves a result, such as count or write |
| Shuffle | Moving rows between machines so the same key lands together |
| Stage | A group of tasks that can run without a shuffle in the middle |
| Partition | One slice of a dataset. One task works on one partition |
| Data skew | One key has far more rows than the others, so one task is very slow |
| Choice | We gain | We lose |
|---|---|---|
| MapReduce | Very robust, simple model | Slow for multi-step and iterative jobs |
| Spark in memory | Speed on repeated passes | Needs enough memory, or spills to disk |
| HDFS storage | Data next to compute, no cloud fees | You run and repair the cluster |
| Object storage + Spark | Separate storage and compute, scale each | Network reads, slower listing and renames |
| Spark SQL / DataFrame | Optimiser helps | Less control than hand-written code |