A topic in the Open Knowledge Graph — a free, open map of 15,495 topics and the order to learn them in.

MapReduce and Batch Data Processing

Graduate Depth 102 in the knowledge graph ☐ I know this ☆ Set as goal
526prerequisites beneath it
See this on the map →
Hash TablesIntroduction to Distributed Systems+3 more→
MapReduce batch-processing Hadoop shuffle data-parallelism fault-tolerance big-data

Core Idea

MapReduce is a programming model for processing very large datasets on clusters of ordinary machines. The programmer writes two functions: map, which turns each input record into intermediate key-value pairs, and reduce, which receives one key with all of its values and produces the output for that key. The framework handles everything else: splitting the input, running thousands of tasks in parallel, grouping intermediate pairs by key (the shuffle), and re-running tasks on machines that fail. Jeffrey Dean and Sanjay Ghemawat described Google's system in 2004, and Apache Hadoop became its widely used open-source counterpart.

How It's Best Learned

Start with word count on paper: split a short text into three chunks, apply map to each, sort and group the pairs by word, and apply reduce. Then write map and reduce for a second task, such as building an inverted index or counting page views per URL, without being told the answer. Finally, examine what the runtime does when a worker dies midway, and why the model struggles with algorithms that repeat many passes over the same data.

Common Misconceptions

Explainer

Suppose you must count how often each word appears in a billion web pages. One machine would take weeks. Spreading the work over a thousand machines is the obvious answer, but then you must split the data, run tasks, move partial results, and cope with the fact that in a cluster that large some machine is likely to fail during the job. MapReduce lets programmers ignore almost all of that.

The model is drawn from the map and reduce operations of functional programming. The programmer writes two functions:

The framework runs the job in three phases. In the map phase, the input, stored in a distributed file system, is divided into splits, typically 16 to 64 MB each in the original paper. The master assigns map tasks to workers, preferring machines that already hold a copy of the split, so little data crosses the network. Each mapper divides its output into R partitions, usually by hash(key) mod R. In the shuffle, each reducer fetches its partition from every mapper and sorts by key, so that all values for one key end up together. In the reduce phase, the reducer calls reduce once per key and writes its output to the distributed file system.

Fault tolerance is built into the design. The master pings workers. If one stops responding, the master reschedules its tasks on other machines. Re-execution is safe because map and reduce are expected to be deterministic and to have no side effects. Near the end of a job, the master also starts backup copies of the slowest remaining tasks, called stragglers, and uses whichever copy finishes first.

Optional extras improve performance. A combiner pre-aggregates each mapper's output locally before the shuffle. A custom partitioner controls which keys go to which reducer.

Google's 2004 paper by Dean and Ghemawat inspired Apache Hadoop, which brought the model to many companies. Its main weakness is that each job writes its results to disk before the next one starts, which slows iterative and interactive work. Later systems such as Apache Spark keep the same data-parallel idea but hold intermediate data in memory.

Practice Questions 4 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Regular Language Recognition Algorithms → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Context-Free Grammar Properties and Ambiguity → Parse Trees, Derivations, and Ambiguity in CFGs → Context-Free Grammars in Compiler Design → Compiler Phases and Organization → Grammar Design for Compilation → Domain-Specific Language Design and Implementation → Programming Language Semantics → Functional Programming Paradigm → MapReduce and Batch Data Processing

Longest path: 103 steps · 526 total prerequisite topics

Prerequisites (5)

Leads To (0)

No topics depend on this one yet.