Distributed Processing and Map-Reduce
Context: FIT1043_MOC Β· break computation up to scale past one machine Β· the paradigm behind Spark Β· processes Big Data
Quick Revision
- π― Objective: scale computation by splitting it across machines β Map-Reduce = data-parallel map then a reduce (merge).
- π¦ Core Components: processing modes (interactive / streaming / batch) | data-parallel map | key-based reduce.
- β‘ Key Constraint: it only works when the work is data-parallel β independent chunks that can be processed separately, then merged.
π How It Works
1. Processing Modes
- Interactive β humans in the loop.
- Streaming β massive data flows through the system with little storage (real-time).
- Batch β data stored, analysed in large blocks (βbatchesβ) β easier to develop/analyse (offline).
2. Background Concepts
- In-memory β in RAM, not going to disk (fast, volatile); vs HDD/SSD (permanent).
- Parallel processing β tasks run at the same time; distributed computing β across multiple machines.
- Scalability β handle growing work by enlarging capacity (not just βbigβ).
- Data-parallel β processing done independently on separate chunks of data β the prerequisite for Map-Reduce.
- Legacy limit β desktop tools (SAS/R/Matlab) often lack distributed support; distributing needs algorithm redesign.
3. Map-Reduce
- Origin β a simple distributed framework from Google (Dean & Ghemawat, 2004); runs on commodity hardware with fault tolerance.
- Pattern β (1) divide data across machines β (2) map() each record to key-value pairs β (3) sort/merge identical keys β (4) reduce (merge) per key.
- History β Google moved on (~2005) to βCloud Dataflowβ; the idea lives on in Hadoop/Spark.
π Exam Execution Trace
Manual Execution Trace β word count
| Step / State | Action | Result |
|---|---|---|
| 0 (Init) | split text across nodes | shards on machines |
| 1 (map) | each word β (word, 1) | ("the",1) ("cat",1) ("the",1) |
| 2 (sort/shuffle) | group by key | ("the",[1,1]) ("cat",[1]) |
| 3 (reduce) | sum values per key | ("the",2) ("cat",1) |
Final Extracted Output: per-word counts, computed data-parallel then merged β scales to huge corpora on commodity machines.
When It Flips: streaming vs batch is the axis behind Hadoop and Spark β Netflix's pipeline handles ~500 billion events / 1.3 PB per day (β8M events/sec at peak) by streaming (Kafka + Spark), not overnight batch.
π§ Active Recall
Walk through Map-Reduce on a word-count task, and state its precondition.
Answer
- Short answer: Divide the text across machines;
mapemits(word, 1)pairs; sort/shuffle groups identical keys;reducesums the counts per word. Precondition: the work must be data-parallel (independent chunks).- Why: Map (parallel) + reduce (merge) β independent mapping scales horizontally, then a keyed merge combines partial results.
Distinguish batch, streaming, and interactive processing.
Answer
- Short answer: Batch stores data and analyses it in large blocks (offline); streaming processes a massive flow in real time with little storage; interactive brings a human into the loop.
- Why: Storage vs latency β batch trades latency for simplicity; streaming trades storage for real-time results.