Dean 08 Map Reduce
Dean 08 Map Reduce
on Large Clusters
by Jeffrey Dean and Sanjay Ghemawat
Abstract
Biographies
Jeff Dean ([email protected]) is a Google Fellow and is currently working on a large variety of large-scale distributed systems at Googles Mountain View, CA, facility.
Sanjay Ghemawat ([email protected]) is a Google Fellow and works
on the distributed computing infrastructure used by most the companys
products. He is based at Googles Mountain View, CA, facility.
2 Programming Model
The computation takes a set of input key/value pairs, and produces a
set of output key/value pairs. The user of the MapReduce library
expresses the computation as two functions: map and reduce.
Map, written by the user, takes an input pair and produces a set of
intermediate key/value pairs. The MapReduce library groups together
all intermediate values associated with the same intermediate key I
and passes them to the reduce function.
The reduce function, also written by the user, accepts an intermediate key I and a set of values for that key. It merges these values
together to form a possibly smaller set of values. Typically just zero or
one output value is produced per reduce invocation. The intermediate
values are supplied to the users reduce function via an iterator. This
allows us to handle lists of values that are too large to fit in memory.
2.1 Example
Consider the problem of counting the number of occurrences of each
word in a large collection of documents. The user would write code
similar to the following pseudocode.
107
2.2 Types
Even though the previous pseudocode is written in terms of string
inputs and outputs, conceptually the map and reduce functions supplied by the user have associated types.
map
reduce
(k1,v1)
(k2,list(v2))
list(k2,v2)
list(v2)
That is, the input keys and values are drawn from a different domain
than the output keys and values. Furthermore, the intermediate keys
and values are from the same domain as the output keys and values.
3. Implementation
Many different implementations of the MapReduce interface are possible. The right choice depends on the environment. For example, one
implementation may be suitable for a small shared-memory machine,
another for a large NUMA multiprocessor, and yet another for an even
larger collection of networked machines. Since our original article, several open source implementations of MapReduce have been developed
[1, 2], and the applicability of MapReduce to a variety of problem
domains has been studied [7, 16].
This section describes our implementation of MapReduce that is targeted to the computing environment in wide use at Google: large clusters
of commodity PCs connected together with switched Gigabit Ethernet
[4]. In our environment, machines are typically dual-processor x86
processors running Linux, with 4-8GB of memory per machine.
Individual machines typically have 1 gigabit/second of network bandwidth, but the overall bisection bandwidth available per machine is con108
User
Program
(1) fork
(1) fork
(1) fork
Master
(2)
assign
map
(2)
assign
reduce
worker
split 0
split 1
split 2
(3) read
te
emo
(5) rread
(5)
worker
(6) write
output
file 0
worker
split 3
split 4
worker
output
file 1
Reduce
phase
Output
files
worker
Input
files
Map
phasr
Intermediate files
(on local disks)
109
3.4 Locality
Network bandwidth is a relatively scarce resource in our computing environment. We conserve network bandwidth by taking advantage of the
fact that the input data (managed by GFS [10]) is stored on the local
disks of the machines that make up our cluster. GFS divides each file
into 64MB blocks and stores several copies of each block (typically 3
copies) on different machines. The MapReduce master takes the location information of the input files into account and attempts to schedule
a map task on a machine that contains a replica of the corresponding
input data. Failing that, it attempts to schedule a map task near a replica
of that tasks input data (e.g., on a worker machine that is on the same
network switch as the machine containing the data). When running large
MapReduce operations on a significant fraction of the workers in a cluster, most input data is read locally and consumes no network bandwidth.
4 Refinements
Although the basic functionality provided by simply writing map and
reduce functions is sufficient for most needs, we have found a few
extensions useful. These include:
user-specified partitioning functions for determining the mapping
of intermediate key values to the R reduce shards;
ordering guarantees: Our implementation guarantees that within
each of the R reduce partitions, the intermediate key/value pairs are
processed in increasing key order;
user-specified combiner functions for doing partial combination of
generated intermediate values with the same key within the same
map task (to reduce the amount of intermediate data that must be
transferred across the network);
custom input and output types, for reading new input formats and
producing new output formats;
a mode for execution on a single machine for simplifying debugging
and small-scale testing.
The original article has more detailed discussions of each of these
items [8].
5 Performance
In this section, we measure the performance of MapReduce on two computations running on a large cluster of machines. One computation
searches through approximately one terabyte of data looking for a particular pattern. The other computation sorts approximately one terabyte of data.
These two programs are representative of a large subset of the real
programs written by users of MapReduceone class of programs
shuffles data from one representation to another, and another class
extracts a small amount of interesting data from a large dataset.
The sorting program consists of less than 50 lines of user code. The
final sorted output is written to a set of 2-way replicated GFS files (i.e.,
2 terabytes are written as the output of the program).
As before, the input data is split into 64MB pieces (M = 15000). We
partition the sorted output into 4000 files (R = 4000). The partitioning
function uses the initial bytes of the key to segregate it into one of pieces.
Our partitioning function for this benchmark has built-in knowledge of the distribution of keys. In a general sorting program, we would
add a prepass MapReduce operation that would collect a sample of the
keys and use the distribution of the sampled keys to compute splitpoints for the final sorting pass.
All of the programs were executed on a cluster that consisted of approximately 1800 machines. Each machine had two 2GHz Intel Xeon
processors with Hyper-Threading enabled, 4GB of memory, two
160GB IDE disks, and a gigabit Ethernet link. The machines were
arranged in a two-level tree-shaped switched network with approximately 100-200Gbps of aggregate bandwidth available at the root. All of
the machines were in the same hosting facility and therefore the roundtrip time between any pair of machines was less than a millisecond.
Out of the 4GB of memory, approximately 1-1.5GB was reserved by
other tasks running on the cluster. The programs were executed on a
weekend afternoon when the CPUs, disks, and network were mostly idle.
5.2 Grep
The grep program scans through 1010 100-byte records, searching for a relatively rare three-character pattern (the pattern occurs in 92,337 records).
The input is split into approximately 64MB pieces (M = 15000), and the
entire output is placed in one file (R = 1).
5.3 Sort
The sort program sorts 1010 100-byte records (approximately 1 terabyte
of data). This program is modeled after the TeraSort benchmark [12].
111
than for grep. This is because the sort map tasks spend about half their
time and I/O bandwidth writing intermediate output to their local disks.
The corresponding intermediate output for grep had negligible size.
A few things to note: the input rate is higher than the shuffle rate
and the output rate because of our locality optimization; most data is
read from a local disk and bypasses our relatively bandwidth constrained network. The shuffle rate is higher than the output rate
because the output phase writes two copies of the sorted data (we
make two replicas of the output for reliability and availability reasons).
We write two replicas because that is the mechanism for reliability and
availability provided by our underlying file system. Network bandwidth
requirements for writing data would be reduced if the underlying file
system used erasure coding [15] rather than replication.
The original article has further experiments that examine the
effects of backup tasks and machine failures [8].
6 Experience
We wrote the first version of the MapReduce library in February of
2003 and made significant enhancements to it in August of 2003,
including the locality optimization, dynamic load balancing of task execution across worker machines, etc. Since that time, we have been
pleasantly surprised at how broadly applicable the MapReduce library
has been for the kinds of problems we work on. It has been used
across a wide range of domains within Google, including:
large-scale machine learning problems,
clustering problems for the Google News and Froogle products,
extracting data to produce reports of popular queries (e.g. Google
Zeitgeist and Google Trends),
extracting properties of Web pages for new experiments and products (e.g. extraction of geographical locations from a large corpus of
Web pages for localized search),
processing of satellite imagery data,
language model processing for statistical machine translation, and
large-scale graph computations.
Aug. 04
29
634
217
3,288
758
193
157
Mar. 06
171
874
2,002
52,254
6,743
2,970
268
Sep. 07
2,217
395
11,081
403,152
34,774
14,018
394
395
269
1958
1208
4083
2418
At the end of each job, the MapReduce library logs statistics about
the computational resources used by the job. In Table I, we show some
statistics for a subset of MapReduce jobs run at Google in various
months, highlighting the extent to which MapReduce has grown and
become the de facto choice for nearly all data processing needs at Google.
Acknowledgements
Josh Levenberg has been instrumental in revising and extending the userlevel MapReduce API with a number of new features. We would like to especially thank others who have worked on the system and all the users of
MapReduce in Googles engineering organization for providing helpful
feedback, suggestions, and bug reports.
References
7 Related Work
Many systems have provided restricted programming models and used
the restrictions to parallelize the computation automatically. For example,
an associative function can be computed over all prefixes of an N element
array in log N time on N processors using parallel prefix computations [6,
11, 14]. MapReduce can be considered a simplification and distillation of
some of these models based on our experience with large real-world computations. More significantly, we provide a fault-tolerant implementation
that scales to thousands of processors. In contrast, most of the parallel
processing systems have only been implemented on smaller scales and
leave the details of handling machine failures to the programmer.
Our locality optimization draws its inspiration from techniques
such as active disks [13, 17], where computation is pushed into processing elements that are close to local disks, to reduce the amount of
data sent across I/O subsystems or the network.
The sorting facility that is a part of the MapReduce library is similar in operation to NOW-Sort [3]. Source machines (map workers)
partition the data to be sorted and send it to one of R reduce workers.
Each reduce worker sorts its data locally (in memory if possible). Of
course NOW-Sort does not have the user-definable map and reduce
functions that make our library widely applicable.
BAD-FS [5] and TACC [9] are two other systems that rely on reexecution as a mechanism for implementing fault tolerance.
The original article has a more complete treatment of related work [8].
Conclusions
The MapReduce programming model has been successfully used at
Google for many different purposes. We attribute this success to several
reasons. First, the model is easy to use, even for programmers without experience with parallel and distributed systems, since it hides the details
of parallelization, fault tolerance, locality optimization, and load balancing. Second, a large variety of problems are easily expressible as MapReduce computations. For example, MapReduce is used for the generation
of data for Googles production Web search service, for sorting, data mining, machine learning, and many other systems. Third, we have developed
an implementation of MapReduce that scales to large clusters of machines comprising thousands of machines. The implementation makes
efficient use of these machine resources and therefore is suitable for use
on many of the large computational problems encountered at Google.
By restricting the programming model, we have made it easy to parallelize and distribute computations and to make such computations
fault tolerant. Second, network bandwidth is a scarce resource. A
number of optimizations in our system are therefore targeted at reducing the amount of data sent across the network: the locality optimization allows us to read data from local disks, and writing a single copy
of the intermediate data to local disk saves network bandwidth. Third,
redundant execution can be used to reduce the impact of slow
machines, and to handle machine failures and data loss.
1.
2.
3. Arpaci-Dusseau, A. C., Arpaci-Dusseau, R. H., Culler, D. E., Hellerstein, J. M., and Patterson, D. A. 1997. High-performance sorting on
networks of workstations. In Proceedings of the 1997 ACM SIGMOD
International Conference on Management of Data. Tucson, AZ.
4
Barroso, L. A., Dean, J., and Urs Hlzle, U. 2003. Web search for a
planet: The Google cluster architecture. IEEE Micro 23, 2, 22-28.
113