Professional Documents
Culture Documents
Introduction To: Ma Ed
Introduction To: Ma Ed
MapReduce
Acknowledgement
Most of the slides are from Dr. Bing
Chen,
http://grid.hust.edu.cn/chengbin/
Some slides are from SHADI
IBRAHIM,
http://grid.hust.edu.cn/shadi/
What is MapReduce
Motivation
Lots of demands for very large scale
data processing
A certain common themes for these
demands
Lots of machines needed (scaling)
Two basic operations on the input
Map
Reduce
Distributed Grep
matches
Split data
grep
grep
grep
Split data
grep
matches
Split data
Very
big
data
Split data
matches
matches
cat
All
matches
count
Split data
count
count
count
Split data
count
count
Split data
Very
big
data
Split data
count
count
merge
merged
count
Map+Reduce
Very
big
data
M
A
P
Map:
Accepts input
key/value pair
Emits intermediate
key/value pair
Partitioning
Function
R
E
D
U
C
E
Reduce :
Accepts
intermediate
key/value* pair
Emits output
key/value pair
Result
Architecture overview
Master node
user
Job tracker
Slave node N
Slave node 1
Slave node 2
Task tracker
Task tracker
Task tracker
Workers
Workers
Workers
GFS architecture
GFS Master
Client
C0
C1
C5
C2
C1
C5
C3
Chunkserver 1Chunkserver 2
C0
C5
C2
Chunkserver N
Reduce
Merge all intermediate values
associated with the same key
Partition
By default : hash(key) mod R
Well balanced
Diagram (1)
Diagram (2)
A Simple Example
map(stringvalue)
//key:documentname
//value:documentcontents
foreachwordwinvalue
EmitIntermediate(w,1);
reduce(stringkey,iteratorvalues)
//key:word
//values:listofcounts
intresults=0;
foreachvinvalues
result+=ParseInt(v);
Emit(AsString(result));
Locality issue
Master scheduling policy
Asks GFS for locations of replicas of input file
blocks
Map tasks typically split into 64MB (== GFS
block size)
Map tasks scheduled so GFS input block replica
are on same machine or same rack
Effect
Thousands of machines read input at local disk
speed
Without this, rack switches limit read rate
Fault Tolerance
Reactive way
Worker failure
Heartbeat, Workers are periodically pinged by master
NO response = failed worker
Master failure
Master writes periodic checkpoints
Another master can be started from the last
checkpointed state
If eventually the master dies, the job will be aborted
Fault Tolerance
Proactive way (Redundant
Execution)
The problem of stragglers (slow
workers)
Other jobs consuming resources on machine
Bad disks with soft errors transfer data very
slowly
Weird things: processor caches disabled (!!)
Fault Tolerance
Input error: bad records
Map/Reduce functions sometimes fail for
particular inputs
Best solution is to debug & fix, but not always
possible
On segment fault
Send UDP packet to master from signal handler
Include sequence number of record being processed
Status monitor
Refinements
Task Granularity
Minimizes time for fault recovery
load balancing
Points need to be
emphasized
Examples as follows
distributed grep
distributed sort
term-vector / host
document clustering
machine learning
...
...
...
How to use it
User to do list:
indicate:
Input/output files
M: number of map tasks
R: number of reduce tasks
W: number of machines
Main
Applications
MapReduce
Implementations
MapReduce
Cluster,
1, Google
2, Apache Hadoop
Multicore CPU,
Phoenix @ stanford
GPU,
Mars@HKUST
Hadoop
Open source
Java-based implementation of
MapReduce
Use HDFS as underlying file system
Hadoop
Google
Yahoo
MapReduce
Hadoop
GFS
HDFS
Bigtable
HBase
Chubby
Phoenix
The best paper at HPCA07
MapReduce for multiprocessor systems
Shared-memory implementation of MapReduce
SMP, Multi-core
Features
Uses thread instead of cluster nodes for parallelism
Communicate through shared memory instead of
network messages
Dynamic scheduling, locality management, fault
recovery
Workflow
User-defined functions
Implementation of Mars
User applications.
MapReduce
CUDA
System calls
Implementation of Mars
Discussion
We have MPI and PVM,Why do we need MapReduce?
MPI, PVM
MapReduce
Objective
General distributed
programming model
Large-scale data
processing
Availability
Weaker, harder
better
Data
Locality
Usability
MPI-IO
GFS
Difficult to learn
easier
Conclusions
Provide a general-purpose model to
simplify large-scale computation
Allow users to focus on the problem
without worrying about details
References
Original paper
(http://labs.google.com/papers/mapr
educe.html)
On wikipedia (
http://en.wikipedia.org/wiki/MapRedu
ce
)
Hadoop MapReduce in Java (
http://lucene.apache.org/hadoop/)
http://code.google.com/edu/parallel/
mapreduce-tutorial.html