Map Reduce
Map Reduce
Eva Kalyvianaki
[email protected]
Contents
2
Motivation: Processing Large-sets of Data
Need for many computations over large/huge sets of data:
Input data: crawled documents, web request logs
Output data: inverted indices, summary of pages crawled per host, the
set of the most frequent queries in a given day, …
Most of these computation are relatively straight-forward
To speedup computation and shorten processing time, we can
distribute data across 100s of machines and process them in
parallel
But, parallel computations are difficult and complex to manage:
Race conditions, debugging, data distribution, fault-tolerance, load
balancing, etc
Programming model:
Provides abstraction to express computation
Library:
To take care the runtime parallelisation of the computation.
4
Example: Counting the number of occurrences of each
work in the text below from Wikipedia
“Cloud computing is a recently evolved computing terminology
or metaphor based on utility and consumption of computing
resources. Cloud computing involves deploying groups of
remote servers and software networks that allow centralized
data storage and online access to computer services or
resources. Cloud can be classified as public, private or
hybrid.”
2. Reduce task: all intermediate pairs with the same kint a list of values
reduce(out-key, list(intermediate-value)) list(out-values)
< kint, {vint} > < ko, vo >
6
Example: Counting the number of occurrences of each
work in a collection of documents
8
MapReduce Implementation
9
Google File System (GFS)
File is divided into several chunks of predefined size;
Typically, 16-64 MB
The system replicates each chunk by a number:
Usually three replicas
To achieve fault-tolerance, availability and reliability
10
Parallel Execution
User specifies:
M: number of map tasks
R: number of reduce tasks
Map:
MapReduce library splits the input file into M pieces
Typically 16-64MB per piece
Map tasks are distributed across the machines
Reduce:
Partitioning the intermediate key space into R pieces
hash(intermediate_key) mod R
Typical setting:
2,000 machines
M = 200,000
R = 5,000
11
Execution Flow
12
Master Data Structures
13
Fault-Tolerance
Two types of failures:
1. worker failures:
Identified by sending heartbeat messages by the master. If no
response within a certain amount of time, then the worker is dead.
In-progress and completed map tasks are re-scheduled idle
In-progress reduce tasks are re-scheduled idle
Workers executing reduce tasks affected from failed map/workers are
notified of re-scheduling
Question: Why completed tasks have to be re-scheduler?
Answer: Map output is stored on local fs, while reduce output is stored
on GFS
2. master failure:
1. Rare
2. Can be recovered from checkpoints
3. Solution: aborts the MapReduce computation and starts again
14
Disk Locality
Use of GFS that stores typically three copies of the data block
on different machines
Map tasks are scheduled “close” to data
On nodes that have input data (local disk)
If not, on nodes that are nearer to input data (e.g., same switch)
15
Task Granularity
Number of map tasks > number of worker nodes
Better load balancing
Better recovery
16
Stragglers
Slow workers delay overall completion time stragglers
Bad disks with soft errors
Other tasks using up resources
Machine configuration problems, etc
17
Refinements: Partitioning Function
18
Refinements: Combiner Function
19
Evaluation - Setup
Evaluation on two programs running on a large cluster and
processing 1 TB of data:
1. grep: search over 1010 100-byte records looking for a rare 3-character
pattern
2. sort: sorts 1010 100-byte records
Cluster configuration:
1,800 machines
Each machine has 2 GHz Intel Xeon proc., 4GB mem, 2 160GB IDE disks
Gigabit Ethernet link
Hosted in the same facility
20
Grep
M = 15,000 of 64MB each split
R=1
Entire computation finishes at 150s
Startup overhead ~60s
Propagation of program to workers
Delays to interact with GFS to open 1,000 files
…
Picks at 30GB/s with 1,764 workers
21
Sort
M = 15,000 splits, 64MB each
R = 4,000 files
Workers = 1,700
Evaluated on three executions:
With backup tasks
Without backup tasks
With machine failures
22
Sort Results
Top: rate at which input is read
Middle: rate at which data is sent from mappers to reducers
Bottom: rate at which sorted data is written to output file by reducers
24
Summary
25