7. ado op o ften.
I u se H
d my Tivo
the s oun
Th at’s I s kip a
very time
ma kes e
com mer cial.
rrency in Practice
Ja va Concu
n Goetz, author of
-Bria
44. Applications
Protein folding
pharmaceutical research
Search Engine Indexing
walking billions of web pages
Product Recommendations
based on other customer purchases
Sorting
terabytes to petabyes in size
Classification
government intelligence
46. SELECT reccProd.name, reccProd.id
FROM products reccProd
WHERE purchases.customerId =
(SELECT customerId
FROM customers
WHERE purchases.productId = thisProd)
LIMIT 5
51. MapReduce: Simplified Data
Processing on Large Clusters
Jeffrey Dean and Sanjay Ghem
awat
jeff@google.com, sanjay@goog
le.com
Google, Inc.
Abstract
given day, etc. Most such com
MapReduce is a programmin putations are conceptu-
g model and an associ- ally straightforward. However
ated implementation for proc , the input data is usually
essing and generating large large and the computations have
data sets. Users specify a map to be distributed across
function that processes a hundreds or thousands of mac
key/value pair to generate a set hines in order to finish in
of intermediate key/value a reasonable amount of time.
pairs, and a reduce function that The issues of how to par-
merges all intermediate allelize the computation, dist
values associated with the sam ribute the data, and handle
e intermediate key. Many failures conspire to obscure the
real world tasks are expressible original simple compu-
in this model, as shown tation with large amounts of
in the paper. complex code to deal with
these issues.
Programs written in this func As a reaction to this complex
tional style are automati- ity, we designed a new
cally parallelized and executed abstraction that allows us to exp
on a large cluster of com- ress the simple computa-
modity machines. The run-time tions we were trying to perform
system takes care of the but hides the messy de-
details of partitioning the inpu tails of parallelization, fault-tol
t data, scheduling the pro- erance, data distribution
gram’s execution across a set and load balancing in a libra
of machines, handling ma- ry. Our abstraction is in-
chine failures, and managing spired by the map and reduce
the required inter-machine primitives present in Lisp
communication. This allows and many other functional lang
programmers without any uages. We realized that
experience with parallel and most of our computations invo
distributed systems to eas- lved applying a map op-
ily utilize the resources of a larg eration to each logical “record”
e distributed system. in our input in order to
Our implementation of Map compute a set of intermediat
Reduce runs on a large e key/value pairs, and then
cluster of commodity machine applying a reduce operation to
s and is highly scalable: all the values that shared
a typical MapReduce computa the same key, in order to com
tion processes many ter- bine the derived data ap-
abytes of data on thousands of propriately. Our use of a func
machines. Programmers tional model with user-
find the system easy to use: hun specified map and reduce ope
dreds of MapReduce pro- rations allows us to paral-
grams have been implemente lelize large computations easi
d and upwards of one thou- ly and to use re-execution
sand MapReduce jobs are exec as the primary mechanism for
uted on Google’s clusters fault tolerance.
every day. The major contributions of this
work are a simple and
powerful interface that enables
automatic parallelization
and distribution of large-scale
computations, combined
1 Introduction with an implementation of this
interface that achieves
high performance on large clus
ters of commodity PCs.
Over the past five years, the Section 2 describes the basic
authors and many others at programming model and
Google have implemented hun gives several examples. Sec
dreds of special-purpose tion 3 describes an imple-
computations that process larg mentation of the MapReduce
e amounts of raw data, interface tailored towards
such as crawled documents, our cluster-based computing
web request logs, etc., to environment. Section 4 de-
compute various kinds of deri scribes several refinements of
ved data, such as inverted the programming model
indices, various representatio that we have found useful. Sec
ns of the graph structure tion 5 has performance
of web documents, summaries measurements of our implem
of the number of pages entation for a variety of
crawled per host, the set of tasks. Section 6 explores the
most frequent queries in a use of MapReduce within
Google including our experie
nces in using it as the basis
To appear in OSDI 2004
1
52. mode l and
gram ming
“ A pro for
ment ation
imple
nd ge nera ting
pro cess ing a
dat a s ets ”
la rg e
69. /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.mapred.lib;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
70. /** A {@link Mapper} that extracts text matching a regular expression.
*/
public class RegexMapper<K> extends MapReduceBase
implements Mapper<K, Text, Text, LongWritable> {
private Pattern pattern;
private int group;
public void configure(JobConf job) {
pattern = Pattern.compile(job.get("mapred.mapper.regex"));
group = job.getInt("mapred.mapper.regex.group", 0);
}
public void map(K key, Text value,
OutputCollector<Text, LongWritable> output,
Reporter reporter)
throws IOException {
String text = value.toString();
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
output.collect(new Text(matcher.group(group)), new LongWritable
(1));
}
}
}
71. Have Code,
Will Travel
Code travels to the data
Opposite of traditional systems
74. uted file
alab le di strib
“sc ibuted
r large distr
s yst em fo icati ons.
nsive appl
d ata-inte ance
fa ult t oler
ovides
It pr
in expensive
e runn ing on
whil
ty h ardw are”
com modi
75. HDFS Basics
Open Source implementation of
Google BigTable
Replicated data store
Stored in 64MB blocks
76. HDFS
Rack location aware
Configurable redundancy factor
Self-healing
Looks almost like *NIX filesystem
95. server Funerals
No pagers go off when machines die
Report of dead machines once a week
Clean out the carcasses
96. ss attributes
Ro bustne eding
ed fro m ble
p revent
plication code
into ap
Data redundancy
Node death
Retries
Data geography
Parallelism
Scalability
128. PIG Questions
Ask big questions on unstructured
data
How many ___?
Should we ____?
Decide on the questions you want to
ask long after you’ve collected the
data.
129. Pig Data
999991,female,Mary,T,Hargrave,600 Quiet Valley Lane,Los Angeles,CA,90017,US,Mary.T.Hargrave@dodgit.com,
999992,male,Harold,J,Candelario,294 Ford Street,OAKLAND,CA,94607,US,Harold.J.Candelario@dodgit.com,ad2U
999993,female,Ruth,G,Carter,4890 Murphy Court,Shakopee,MN,55379,US,Ruth.G.Carter@mailinator.com,uaseu8e
999994,male,Lionel,J,Carter,2701 Irving Road,Saint Clairsville,OH,43950,US,Lionel.J.Carter@trashymail.c
999995,female,Georgia,C,Medina,4541 Cooks Mine Road,CLOVIS,NM,88101,US,Georgia.C.Medina@trashymail.com,
999996,male,Stanley,S,Cruz,1463 Jennifer Lane,Durham,NC,27703,US,Stanley.S.Cruz@pookmail.com,aehoh5rooG
999997,male,Justin,A,Delossantos,3169 Essex Court,MANCHESTER,VT,05254,US,Justin.A.Delossantos@mailinato
999998,male,Leonard,K,Baker,4672 Margaret Street,Houston,TX,77063,US,Leonard.K.Baker@trashymail.com,Aep
999999,female,Charissa,J,Thorne,2806 Cedar Street,Little Rock,AR,72211,US,Charissa.J.Thorne@trashymail.
1000000,male,Michael,L,Powell,2797 Turkey Pen Road,New York,NY,10013,US,Michael.L.Powell@mailinator.com
130. Pig Sample
Person = LOAD 'people.csv' using PigStorage(',');
Names = FOREACH Person GENERATE $2 AS name;
OrderedNames = ORDER Names BY name ASC;
GroupedNames = GROUP OrderedNames BY name;
NameCount = FOREACH GroupedNames
GENERATE group, COUNT(OrderedNames);
store NameCount into 'names.out';
163. Commodity
1..N
TaskTracker
h
dfs.s
Robust, Primary rt-
1 sta h DataNode
e d.s
-m apr
s tart
start-all.sh NameNode
Commodity
1..N
JobTracker sta
rt-d
fs.
sta sh
rt-
ma TaskTracker
pr
ed
.sh
DataNode