Petabyte Facebook
Petabyte Facebook
Hadoop
Ashish Thusoo, Joydeep Sen Sarma, Namit Jain, Zheng Shao, Prasad Chakka, Ning Zhang, Suresh Antony, Hao Liu
and Raghotham Murthy
Facebook Data Infrastructure Team
Abstract— The size of data sets being collected and analyzed in data. As a result we started exploring Hadoop as a technology
the industry for business intelligence is growing rapidly, making to address our scaling needs. The fact that Hadoop was
traditional warehousing solutions prohibitively expensive. already an open source project that was being used at petabyte
Hadoop [1] is a popular open-source map-reduce implementation scale and provided scalability using commodity hardware was
which is being used in companies like Yahoo, Facebook etc. to a very compelling proposition for us. The same jobs that had
store and process extremely large data sets on commodity taken more than a day to complete could now be completed
hardware. However, the map-reduce programming model is very within a few hours using Hadoop.
low level and requires developers to write custom programs
However, using Hadoop was not easy for end users,
which are hard to maintain and reuse. In this paper, we present
Hive, an open-source data warehousing solution built on top of especially for those users who were not familiar with map-
Hadoop. Hive supports queries expressed in a SQL-like reduce. End users had to write map-reduce programs for
declarative language - HiveQL, which are compiled into map- simple tasks like getting raw counts or averages. Hadoop
reduce jobs that are executed using Hadoop. In addition, HiveQL lacked the expressiveness of popular query languages like
enables users to plug in custom map-reduce scripts into queries. SQL and as a result users ended up spending hours (if not
The language includes a type system with support for tables days) to write programs for even simple analysis. It was very
containing primitive types, collections like arrays and maps, and clear to us that in order to really empower the company to
nested compositions of the same. The underlying IO libraries can analyze this data more productively, we had to improve the
be extended to query data in custom formats. Hive also includes
query capabilities of Hadoop. Bringing this data closer to
a system catalog - Metastore – that contains schemas and
statistics, which are useful in data exploration, query users is what inspired us to build Hive in January 2007. Our
optimization and query compilation. In Facebook, the Hive vision was to bring the familiar concepts of tables, columns,
warehouse contains tens of thousands of tables and stores over partitions and a subset of SQL to the unstructured world of
700TB of data and is being used extensively for both reporting Hadoop, while still maintaining the extensibility and
and ad-hoc analyses by more than 200 users per month. flexibility that Hadoop enjoyed. Hive was open sourced in
August 2008 and since then has been used and explored by a
I. INTRODUCTION number of Hadoop users for their data processing needs.
Scalable analysis on large data sets has been core to the Right from the start, Hive was very popular with all users
functions of a number of teams at Facebook - both within Facebook. Today, we regularly run thousands of jobs
engineering and non-engineering. Apart from ad hoc analysis on the Hadoop/Hive cluster with hundreds of users for a wide
and business intelligence applications used by analysts across variety of applications starting from simple summarization
the company, a number of Facebook products are also based jobs to business intelligence, machine learning applications
on analytics. These products range from simple reporting and to also support Facebook product features.
applications like Insights for the Facebook Ad Network, to In the following sections, we provide more details about
more advanced kind such as Facebook's Lexicon product [2]. Hive architecture and capabilities. Section II describes the
As a result a flexible infrastructure that caters to the needs of data model, the type systems and the HiveQL. Section III
these diverse applications and users and that also scales up in details how data in Hive tables is stored in the underlying
a cost effective manner with the ever increasing amounts of distributed file system – HDFS(Hadoop file system). Section
data being generated on Facebook, is critical. Hive and IV describes the system architecture and various components
Hadoop are the technologies that we have used to address of Hive . In Section V we highlight the usage statistics of Hive
these requirements at Facebook. at Facebook and provide related work in Section VI. We
The entire data processing infrastructure in Facebook prior conclude with future work in Section VII.
to 2008 was built around a data warehouse built using a
commercial RDBMS. The data that we were generating was II. DATA MODEL, TYPE SYSTEM AND QUERY LANGUAGE
growing very fast - as an example we grew from a 15TB data Hive structures data into the well-understood database
set in 2007 to a 700TB data set today. The infrastructure at concepts like tables, columns, rows, and partitions. It supports
that time was so inadequate that some daily data processing all the major primitive types – integers, floats, doubles and
jobs were taking more than a day to process and the situation strings – as well as complex types such as maps, lists and
was just getting worse with every passing day. We had an structs. The latter can be nested arbitrarily to construct more
urgent need for infrastructure that could scale along with our complex types. In addition, Hive allows users to extend the
Hive also natively supports the following complex types: Note that, if possible, the table schema could also be provided
• Associative arrays – map<key-type, value-type> by composing the complex and primitive types.
• Lists – list<element-type>
• Structs – struct<file-name: field-type, ... >
B. Query Language
These complex types are templated and can be composed to The Hive query language(HiveQL) comprises of a subset of
generate types of arbitrary complexity. For example, SQL and some extensions that we have found useful in our
list<map<string, struct<p1:int, p2:int>> represents a list of environment. Traditional SQL features like from clause sub-
associative arrays that map strings to structs that in turn queries, various types of joins – inner, left outer, right outer
contain two integer fields named p1 and p2. These can all be and outer joins, cartesian products, group bys and
put together in a create table statement to create tables with aggregations, union all, create table as select and many useful
the desired schema. For example, the following statement functions on primitive and complex types make the language
creates a table t1 with a complex schema. very SQL like. In fact for many of the constructs mentioned
before it is exactly like SQL. This enables anyone familiar
CREATE TABLE t1(st string, fl float, li list<map<string, with SQL to start a hive cli(command line interface) and begin
struct<p1:int, p2:int>>); querying the system right away. Useful metadata browsing
capabilities like show tables and describe are also present and
Query expressions can access fields within the structs using a so are explain plan capabilities to inspect query plans (though
'.' operator. Values in the associative arrays and lists can be the plans look very different from what you would see in a
accessed using '[]' operator. In the previous example, [Link][0] traditional RDBMS). There are some limitations e.g. only
gives the first element of the list and [Link][0]['key'] gives the equality predicates are supported in a join predicate and the
struct associated with 'key' in that associative array. Finally joins have to be specified using the ANSI join syntax such as
the p2 field of this struct can be accessed by [Link][0]['key'].p2.
With these constructs Hive is able to support structures of SELECT t1.a1 as c1, t2.b1 as c2
arbitrary complexity. FROM t1 JOIN t2 ON (t1.a2 = t2.b2);
The tables created in the manner describe above are
serialized and deserialized using default serializers and instead of the more traditional
deserializers already present in Hive. However, there are
instances where the data for a table is prepared by some other SELECT t1.a1 as c1, t2.b1 as c2
programs or may even be legacy data. Hive provides the FROM t1, t2
flexibility to incorporate that data into a table without having WHERE t1.a2 = t2.b2;
to transform the data, which can save substantial amount of
time for large data sets. As we will describe in the later Another limitation is in how inserts are done. Hive currently
sections, this can be achieved by providing a jar that does not support inserting into an existing table or data
implements the SerDe java interface to Hive. In such partition and all inserts overwrite the existing data.
situations the type information can also be provided by that jar Accordingly, we make this explicit in our syntax as follows:
997
INSERT OVERWRITE TABLE t1 Note, in the example above there is no map clause which
SELECT * FROM t2; indicates that the input columns are not transformed.
Similarly, it is possible to have a MAP clause without a
In reality these restrictions have not been a problem. We have REDUCE clause in case the reduce phase does not do any
rarely seen a case where the query cannot be expressed as an transformation of data. Also in the examples shown above, the
equi-join and since most of the data is loaded into our FROM clause appears before the SELECT clause which is
warehouse daily or hourly, we simply load the data into a new another deviation from standard SQL syntax. Hive allows
partition of the table for that day or hour. However, we do users to interchange the order of the FROM and
realize that with more frequent loads the number of partitions SELECT/MAP/REDUCE clauses within a given sub-query.
can become very large and that may require us to implement This becomes particularly useful and intuitive when dealing
INSERT INTO semantics. The lack of INSERT INTO, with multi inserts. HiveQL supports inserting different
UPDATE and DELETE in Hive on the other hand do allow us transformation results into different tables, partitions, hdfs or
to use very simple mechanisms to deal with reader and writer local directories as part of the same query. This ability helps
concurrency without implementing complex locking in reducing the number of scans done on the input data as
protocols. shown in the following example:
Apart from these restrictions, HiveQL has extensions to
support analysis expressed as map-reduce programs by users FROM t1
and in the programming language of their choice. This enables INSERT OVERWRITE TABLE t2
advanced users to express complex logic in terms of map- SELECT t3.c2, count(1)
reduce programs that are plugged into HiveQL queries FROM t3
seamlessly. Some times this may be the only reasonable WHERE t3.c1 <= 20
approach e.g. in the case where there are libraries in python or GROUP BY t3.c2
php or any other language that the user wants to use for data
transformation. The canonical word count example on a table INSERT OVERWRITE DIRECTORY '/output_dir'
of documents can, for example, be expressed using map- SELECT t3.c2, avg(t3.c1)
reduce in the following manner: FROM t3
WHERE t3.c1 > 20 AND t3.c1 <= 30
FROM ( GROUP BY t3.c2
MAP doctext USING 'python wc_mapper.py' AS (word, cnt)
FROM docs INSERT OVERWRITE LOCAL DIRECTORY '/home/dir'
CLUSTER BY word SELECT t3.c2, sum(t3.c1)
)a FROM t3
REDUCE word, cnt USING 'python wc_reduce.py'; WHERE t3.c1 > 30
GROUP BY t3.c2;
As shown in this example the MAP clause indicates how the
input columns (doctext in this case) can be transformed using In this example different portions of table t1 are aggregated
a user program (in this case ‘python wc_mapper.py') into and used to generate a table t2, an hdfs directory(/output_dir)
output columns (word and cnt). The CLUSTER BY clause in and a local directory(/home/dir on the user’s machine).
the sub-query specifies the output columns that are hashed on
to distributed the data to the reducers and finally the REDUCE III. DATA STORAGE, SERDE AND FILE FORMATS
clause specifies the user program to invoke (python
A. Data Storage
wc_reduce.py in this case) on the output columns of the sub-
query. Sometimes, the distribution criteria between the While the tables are logical data units in Hive, table
mappers and the reducers needs to provide data to the reducers metadata associates the data in a table to hdfs directories. The
such that it is sorted on a set of columns that are different primary data units and their mappings in the hdfs name space
from the ones that are used to do the distribution. An example are as follows:
could be the case where all the actions in a session need to be • Tables – A table is stored in a directory in hdfs.
ordered by time. Hive provides the DISTRIBUTE BY and • Partitions – A partition of the table is stored in a sub-
SORT BY clauses to accomplish this as shown in the directory within a table's directory.
following example: • Buckets – A bucket is stored in a file within the
partition's or table's directory depending on whether the
FROM ( table is a partitioned table or not.
FROM session_table As an example a table test_table gets mapped to
SELECT sessionid, tstamp, data <warehouse_root_directory>/test_table in hdfs. The
DISTRIBUTE BY sessionid SORT BY tstamp warehouse_root_directory is specified by the
)a [Link] configuration parameter in
REDUCE sessionid, tstamp, data USING 'session_reducer.sh'; [Link]. By default this parameter's value is set to
/user/hive/warehouse.
998
A table may be partitioned or non-partitioned. A partitioned The final storage unit concept that Hive uses is the concept
table can be created by specifying the PARTITIONED BY of Buckets. A bucket is a file within the leaf level directory of
clause in the CREATE TABLE statement as shown below. a table or a partition. At the time the table is created, the user
can specify the number of buckets needed and the column on
CREATE TABLE test_part(c1 string, c2 int) which to bucket the data. In the current implementation this
PARTITIONED BY (ds string, hr int); information is used to prune the data in case the user runs the
query on a sample of data e.g. a table that is bucketed into 32
In the example shown above the table partitions will be stored buckets can quickly generate a 1/32 sample by choosing to
in /user/hive/warehouse/test_part directory in hdfs. A partition look at the first bucket of data. Similarly, the statement
exists for every distinct value of ds and hr specified by the
user. Note that the partitioning columns are not part of the SELECT * FROM t TABLESAMPLE(2 OUT OF 32);
table data and the partition column values are encoded in the
directory path of that partition (they are also stored in the table would scan the data present in the second bucket. Note that
metadata). A new partition can be created through an INSERT the onus of ensuring that the bucket files are properly created
statement or through an ALTER statement that adds a and named are a responsibility of the application and HiveQL
partition to the table. Both the following statements DDL statements do not currently try to bucket the data in a
way that it becomes compatible to the table properties.
INSERT OVERWRITE TABLE Consequently, the bucketing information should be used with
test_part PARTITION(ds='2009-01-01', hr=12) caution.
SELECT * FROM t; Though the data corresponding to a table always resides in
the <warehouse_root_directory>/test_table location in hdfs,
ALTER TABLE test_part Hive also enables users to query data stored in other locations
ADD PARTITION(ds='2009-02-02', hr=11); in hdfs. This can be achieved through the EXTERNAL
TABLE clause as shown in the following example.
add a new partition to the table test_part. The INSERT
statement also populates the partition with data from table t, CREATE EXTERNAL TABLE test_extern(c1 string, c2 int)
where as the alter table creates an empty partition. Both these LOCATION '/user/mytables/mydata';
statements end up creating the corresponding directories -
/user/hive/warehouse/test_part/ds=2009-01-01/hr=12 and With this statement, the user is able to specify that test_extern
/user/hive/warehouse/test_part/ds=2009-02-02/hr=11 – in the is an external table with each row comprising of two columns
table’s hdfs directory. This approach does create some – c1 and c2. In addition the data files are stored in the location
complications in case the partition value contains characters /user/mytables/mydata in hdfs. Note that as no custom SerDe
such as / or : that are used by hdfs to denote directory has been defined it is assumed that the data is in Hive’s
structure, but proper escaping of those characters does take internal format. An external table differs from a normal table
care of a producing an hdfs compatible directory name. in only that a drop table command on an external table only
The Hive compiler is able to use this information to prune drops the table metadata and does not delete any data. A drop
the directories that need to be scanned for data in order to on a normal table on the other hand drops the data associated
evaluate a query. In case of the test_part table, the query with the table as well.
999
As an example, the statement C. File Formats
CREATE TABLE test_delimited(c1 string, c2 int) Hadoop files can be stored in different formats. A file
ROW FORMAT DELIMITED format in Hadoop specifies how records are stored in a file.
FIELDS TERMINATED BY '\002' Text files for example are stored in the TextInputFormat and
LINES TERMINATED BY '\012'; binary files can be stored as SequenceFileInputFormat. Users
can also implement their own file formats. Hive does not
specifies that the data for table test_delimited uses ctrl-B impose an restrictions on the type of file input formats, that
(ascii code 2) as a column delimiter and uses ctrl-L(ascii code the data is stored in. The format can be specified when the
12) as a row delimiter. In addition, delimiters can be specified table is created. Apart from the two formats mentioned above,
to delimit the serialized keys and values of maps and different Hive also provides an RCFileInputFormat which stores the
delimiters can also be specified to delimit the various data in a column oriented manner. Such an organization can
elements of a list (collection). This is illustrated by the give important performance improvements specially for
following statement. queries that do not access all the columns of the table. Users
can add their own file formats and associate them to a table as
CREATE TABLE test_delimited2(c1 string, shown in the following statement.
c2 list<map<string, int>>)
ROW FORMAT DELIMITED CREATE TABLE dest1(key INT, value STRING)
FIELDS TERMINATED BY '\002' STORED AS
COLLECTION ITEMS TERMINATED BY '\003' INPUTFORMAT
MAP KEYS TERMINATED BY '\004'; '[Link]'
OUTPUTFORMAT
Apart from LazySerDe, some other interesting SerDes are '[Link]'
present in the hive_contrib.jar that is provided with the
distribution. A particularly useful one is RegexSerDe which The STORED AS clause specifies the classes to be used to
enables the user to specify a regular expression to parse determine the input and output formats of the files in the
various columns out from a row. The following statement can table’s or partition’s directory. This can be any class that
be used for example, to interpret apache logs. implements the FileInputFormat and FileOutputFormat java
interfaces. The classes can be provded to Hadoop in a jar in
add jar 'hive_contrib.jar'; ways similar to those shown in the examples on adding
CREATE TABLE apachelog( custom SerDes.
host string,
identity string, IV. SYSTEM ARCHITECTURE AND COMPONENTS
user string,
time string,
request string,
status string,
size string,
referer string,
agent string)
ROW FORMAT SERDE
'[Link]'
WITH SERDEPROPERTIES(
'[Link]' = '([^ ]*) ([^ ]*) ([^ ]*) (-|\\[[^\\]]*\\]) ([^
\"]*|\"[^\"]*\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \"]*|\"[^\"]*\") ([^
\"]*|\"[^\"]*\"))?',
'[Link]' = '%1$s %2$s %3$s %4$s %5$s %6$s
%7$s %8$s %9$s');
1000
The following components are the main building blocks in As a result it is important that the information stored in the
Hive: Metastore is backed up regularly. Ideally a replicated server
• Metastore – The component that stores the system should also be deployed in order to provide the availability
catalog and metadata about tables, columns, partitions that many production environments need. It is also important
etc. to ensure that this server is able to scale with the number of
• Driver – The component that manages the lifecycle of a queries submitted by the users. Hive addresses that by
HiveQL statement as it moves through Hive. The driver ensuring that no Metastore calls are made from the mappers or
also maintains a session handle and any session the reducers of a job. Any metadata that is needed by the
statistics. mapper or the reducer is passed through xml plan files that are
• Query Compiler – The component that compiles HiveQL generated by the compiler and that contain any information
into a directed acyclic graph of map/reduce tasks. that is needed at the run time.
• Execution Engine – The component that executes the The ORM logic in the Metastore can be deployed in client
tasks produced by the compiler in proper dependency libraries such that it runs on the client side and issues direct
order. The execution engine interacts with the underlying calls to an RDBMS. This deployment is easy to get started
Hadoop instance. with and ideal if the only clients that interact with Hive are the
• HiveServer – The component that provides a thrift CLI or the web UI. However, as soon as Hive metadata needs
interface and a JDBC/ODBC server and provides a way to get manipulated and queried by programs in languages like
of integrating Hive with other applications. python, php etc., i.e. by clients not written in Java, a separate
• Clients components like the Command Line Interface Metastore server has to be deployed.
(CLI), the web UI and JDBC/ODBC driver.
• Extensibility Interfaces which include the SerDe and B. Query Compiler
ObjectInspector interfaces already described previously The metadata stored in the Metastore is used by the query
as well as the UDF(User Defined Function) and compiler to generate the execution plan. Similar to compilers
UDAF(User Defined Aggregate Function) interfaces that in traditional databases, the Hive compiler processes HiveQL
enable users to define their own custom functions. statements in the following steps:
• Parse – Hive uses Antlr to generate the abstract syntax
A HiveQL statement is submitted via the CLI, the web UI tree (AST) for the query.
or an external client using the thrift, odbc or jdbc interfaces. • Type checking and Semantic Analysis – During this
The driver first passes the query to the compiler where it goes phase, the compiler fetches the information of all the
through the typical parse, type check and semantic analysis input and output tables from the Metastore and uses that
phases, using the metadata stored in the Metastore. The information to build a logical plan. It checks type
compiler generates a logical plan that is then optimized compatibilities in expressions and flags any compile
through a simple rule based optimizer. Finally an optimized time semantic errors at this stage. The transformation of
plan in the form of a DAG of map-reduce tasks and hdfs tasks an AST to an operator DAG goes through an
is generated. The execution engine then executes these tasks intermediate representation that is called the query block
in the order of their dependencies, using Hadoop. (QB) tree. The compiler converts nested queries into
In this section we provide more details on the Metastore, parent child relationships in a QB tree. At the same time,
the Query Compiler and the Execution Engine. the QB tree representation also helps in organizing the
relevant parts of the AST tree in a form that is more
A. Metastore amenable to be transformed into an operator DAG than
The Metastore acts as the system catalog for Hive. It stores the vanilla AST.
all the information about the tables, their partitions, the • Optimization – The optimization logic consists of a
schemas, the columns and their types, the table locations etc. chain of transformations such that the operator DAG
This information can be queried or modified using a thrift resulting from one transformation is passed as input to
([7]) interface and as a result it can be called from clients in the next transformation. Anyone wishing to change the
different programming languages. As this information needs compiler or wishing to add new optimization logic can
to be served fast to the compiler, we have chosen to store this easily do that by implementing the transformation as an
information on a traditional RDBMS. The Metastore thus extension of the Transform interface and adding it to the
becomes an application that runs on an RDBMS and uses an chain of transformations in the optimizer.
open source ORM layer called DataNucleus ([8]), to convert The transformation logic typically comprises of a walk
object representations into a relational schema and vice versa. on the operator DAG such that certain processing actions
We chose this approach as opposed to storing this information are taken on the operator DAG when relevant conditions
in hdfs as we need the Metastore to be very low latency. The or rules are satisfied. The five primary interfaces that are
DataNucleus layer allows us to plugin many different involved in a transformation are Node, GraphWalker,
RDBMS technologies. In our deployment at Facebook, we use Dispatcher, Rule and Processor. The nodes in the
mysql to store this information. operator DAG implement the Node interface. This
Metastore is very critical for Hive. Without the system enables the operator DAG to be manipulated using the
catalog it is not possible to impose a structure on hadoop files. other interfaces mentioned above. A typical
1001
transformation involves walking the DAG and for every ii. Predicate pushdown – Predicates are pushed
Node visited, checking if a Rule is satisfied and then down to the scan if possible so that rows can
invoking the corresponding Processor for that Rule in be filter early in the processing.
case the later is satisfied. The Dispatcher maintains the iii. Partition pruning – Predicates on partitioned
mappings from Rules to Processors and does the Rule columns are used to prune out files of
matching. It is passed to the GraphWalker so that the partitions that do not satisfy the predicate.
appropriate Processor can be dispatched while a Node is iv. Map side joins – In the cases where some of
being visited in the walk. The flowchart in Fig. 2 shows the tables in a join are very small, the small
how a typical transformation is structured. tables are replicated in all the mappers and
joined with other tables. This behavior is
triggered by a hint in the query of the form:
1002
set [Link]=true; make sure that the join is performed only once. The plan for
SELECT t1.c1, sum(t1.c2) the query is shown in Fig 3 below.
FROM t1 The nodes in the plan are physical operators and the edges
GROUP BY t1; represent the flow of data between operators. The last line in
each node represents the output schema of that operator. For
ii. Hash based partial aggregations in the lack of space, we do not describe the parameters specified
mappers – Hash based partial aggregations within each operator node. The plan has three map-reduce
can potentially reduce the data that is sent jobs.
by the mappers to the reducers. This in turn
reduces the amount of time spent in sorting
and merging this data. As a result a lot of
performance gains can be achieved using
this strategy. Hive enables users to control
the amount of memory that can be used on
the mapper to hold the rows in a hash table
for this optimization. The parameter
[Link]
specifies the fraction of mapper memory
that can be used to hold the hash table, e.g.
0.5 would ensure that as soon as the hash
table size exceeds half of the maximum
memory for a mapper, the partial aggregates
stored therein are sent to the reducers. The
parameter [Link]
is also used to control the amount of
memory used in the mappers.
1003
respectively. Thus, the second and third map-reduce jobs wait Added to that the ability of Hadoop to scale to thousands of
for the first map-reduce job to finish. commodity nodes gives us the confidence that we will be able
to scale this infrastructure going forward as well.
C. Execution Engine VI. RELATED WORK
Finally the tasks are executed in the order of their There has been a lot of recent work on petabyte scale data
dependencies. Each dependent task is only executed if all of processing systems, both open-source and commercial.
its prerequisites have been executed. A map/reduce task first Scope[14] is an SQL-like language on top of Microsoft’s
serializes its part of the plan into a [Link] file. This file is proprietary Cosmos map/reduce and distributed file system.
then added to the job cache for the task and instances of Pig[13] allows users to write declarative scripts to process
ExecMapper and ExecReducers are spawned using Hadoop. data. Hive is different from these systems since it provides a
Each of these classes deserializes the [Link] and executes system catalog that persists metadata about tables within the
the relevant part of the operator DAG. The final results are system. This allows hive to function as a traditional
stored in a temporary location. At the end of the entire query, warehouse which can interface with standard reporting tools
the final data is moved to the desired location in case of like MicroStrategy[16]. HadoopDB[15] reuses most of Hive’s
DMLs. In the case of queries the data is served as such from system, except, it uses traditional database instances in each of
the temporary location. the nodes to store data instead of using a distributed file
system.
V. HIVE USAGE IN FACEBOOK
Hive and Hadoop are used extensively in Facebook for VII. CONCLUSIONS AND FUTURE WORK
different kinds of data processing. Currently our warehouse Hive is a work in progress. It is an open-source project, and
has 700TB of data(which comes to 2.1PB of raw space on is being actively worked on by Facebook as well as several
Hadoop after accounting for the 3 way replication). We add external contributors.
5TB(15TB after replication) of compressed data daily. Typical HiveQL currently accepts only a subset of SQL as valid
compression ratio is 1:7 and sometime more than that. On any queries. We are working towards making HiveQL subsume
particular day more than 7500 jobs are submitted to the cluster SQL syntax. Hive currently has a naive rule-based optimizer
and more than 75TB of compressed data is processed every with a small number of simple rules. We plan to build a cost-
day. With the continuous growth in the Facebook network we based optimizer and adaptive optimization techniques to come
see continuous growth in data. At the same time as the up with more efficient plans. We are exploring columnar
company scales, the cluster also has to scale with the growing storage and more intelligent data placement to improve scan
users. performance. We are running performance benchmarks based
More than half the workload is on adhoc queries where as on [9] to measure our progress as well as compare against
the rest is for reporting dashboards. Hive has enabled this kind other systems. In our preliminary experiments, we have been
of workload on the Hadoop cluster in Facebook because of the able to improve the performance of Hadoop itself by ~20%
simplicity with which adhoc analysis can be done. However, compared to [9]. The improvements involved using faster
sharing the same resources by the adhoc users and reporting Hadoop data structures to process the data, for example, using
users presents significant operational challenges because of Text instead of String. The same queries expressed easily in
the unpredictability of adhoc jobs. Many times these jobs are HiveQL had ~20% overhead compared to our optimized
not properly tuned and therefore consume valuable cluster Hadoop implementation, i.e., Hive's performance is on par
resources. This can in turn lead to degraded performance of with the Hadoop code from [9]. We have also run the industry
the reporting queries, many of which are time critical. standard decision support benchmark – TPC-H [11]. Based on
Resource scheduling has been somewhat weak in Hadoop and these experiments, we have identified several areas for
the only viable solution at present seems to be maintaining performance improvement and have begun working on them.
separate clusters for adhoc queries and reporting queries. More details are available in [10] and [12]. We are enhancing
There is also a wide variety in the Hive jobs that are run the JDBC and ODBC drivers for Hive for integration with
daily. They range from simple summarization jobs generating commercial BI tools that only work with traditional relational
different kinds of rollups and cubes to more advanced warehouses. We are exploring methods for multi-query
machine learning algorithms. The system is used by novice optimization techniques and performing generic n-way joins
users as well as advanced users with new users being able to in a single map-reduce job.
use the system immediately or after an hour long beginners
training. ACKNOWLEDGMENT
A result of heavy usage has also lead to a lot of tables
generated in the warehouse and this has in turn tremendously We would like to thank our user and developer community for
increased the need for data discovery tools, especially for new their contributions, with special thanks to Eric Hwang, Yuntao
users. In general the system has enabled us to provide data Jia, Yongqiang He, Edward Capriolo, and Dhruba Borthakur.
processing services to engineers and analysts at a fraction of
the cost of a more traditional warehousing infrastructure.
1004
REFERENCES
[1] Apache Hadoop. Available at [Link]
[2] Facebook Lexicon at [Link]
[3] Hive wiki at [Link]
[4] Hadoop Map-Reduce Tutorial at
[Link]
[5] Hadoop HDFS User Guide at
[Link]
[6] Mysql list partitioning at
[Link]
[7] Apache Thrift. Available at [Link]
[8] DataNucleus .Available at [Link]
[9] A. Pavlo et. al. A Comparison of Approaches to Large-Scale Data
Analysis. In Proc. of ACM SIGMOD, 2009.
[10] Hive Performance Benchmark. Available at
[Link]
[11] TPC-H Benchmark. Available at [Link]
[12] Running TPC-H queries on Hive. Available at
[Link]
[13] Hadoop Pig. Available at [Link]
[14] R. Chaiken, et. al. Scope: Easy and Efficient Parallel Processing of
Massive Data Sets. In Proc. of VLDB, 2008.
[15] HadoopDB Project. Available at
[Link]
[16] MicroStrategy. Available at [Link]
1005