Map Reduce
Map Reduce
MapReduce
Single-node architecture
CPU
Commodity Clusters
Web data sets can be very large
Tens to hundreds of terabytes
Cluster Architecture
2-10 Gbps backbone between racks 1 Gbps between any pair of nodes in a rack Switch Switch
Switch
CPU
Mem Disk
CPU
CPU
Mem Disk
CPU
Mem Disk
Mem Disk
Stable storage
First order problem: if nodes can fail, how can we store data persistently? Answer: Distributed File System
Provides global file namespace Google GFS; Hadoop HDFS; Kosmix KFS
Master node
a.k.a. Name Nodes in HDFS Stores metadata Might be replicated
k
k
k v
k v
reduce
reduce
k k
v v
k v k
k v
MapReduce
Input: a set of key/value pairs User supplies two functions:
map(k,v) list(k1,v1) reduce(k1, list(v1)) v2
reduce(key, values): // key: a word; value: an iterator over counts result = 0 for each count v in values: result += v emit(result)
fork
Master
fork
Output File 1
Data flow
Input, final output are stored on a distributed file system
Scheduler tries to schedule map tasks close to physical storage location of input data
Intermediate results are stored on local FS of map and reduce workers Output is often input to another map reduce task
Coordination
Master data structures
Task status: (idle, in-progress, completed) Idle tasks get scheduled as workers become available When a map task completes, it sends the master the location and sizes of its R intermediate files, one for each reducer Master pushes this info to reducers
Failures
Map worker failure
Map tasks completed or in-progress at worker are reset to idle Reduce workers are notified when task is rescheduled on another worker
Master failure
MapReduce task is aborted and client is notified
Combiners
Often a map task will produce many pairs of the form (k,v1), (k,v2), for the same key k
E.g., popular words in Word Count
Partition Function
Inputs to map tasks are created by contiguous splits of input file For reduce, we need to ensure that records with the same intermediate key end up at the same worker System uses a default partition function e.g., hash(key) mod R Sometimes useful to override
E.g., hash(hostname(URL)) mod R ensures URLs from a host end up in the same output file
Implementations
Google
Not available outside Google
Hadoop
An open-source implementation in Java Uses HDFS for stable storage Download: http://lucene.apache.org/hadoop/
Aster Data
Cluster-optimized SQL Database that also implements MapReduce Made available free of charge for this class
Cloud Computing
Ability to rent computing by the hour
Additional services e.g., persistent storage
We will be using Amazons Elastic Compute Cloud (EC2) Aster Data and Hadoop can both be run on EC2 In discussions with Amazon to provide access free of charge for class
Reading
Jeffrey Dean and Sanjay Ghemawat, MapReduce: Simplified Data Processing on Large Clusters http://labs.google.com/papers/mapreduce.html Sanjay Ghemawat, Howard Gobioff, and ShunTak Leung, The Google File System http://labs.google.com/papers/gfs.html