David J. DeWitt Rimma Nehme

advertisement
David J. DeWitt
dewitt@microsoft.com
Rimma Nehme
rimman@microsoft.com
Microsoft Jim Gray Systems Lab
Madison, Wisconsin
To some, “Big Data” means
using a NoSQL system or
Parallel relational DBMS like
2
If you
Amount of Stored Data By Sector
like analogies…
(in Petabytes, 2009)
1000
900
800
Petabytes
700
600
500
966
848
35ZB = enough data
715
to fill a stack of619
DVDs
reaching halfway to Mars
434
364
400
269
300
227
Mars
200
100
0
Earth
Sources:
"Big Data: The Next Frontier for Innovation, Competition and Productivity."
US Bureau of Labor Statistics | McKinsley Global Institute Analysis
1 zettabyte?
= 1 million petabytes
= 1 billion terabytes
= 1 trillion gigabytes
3

An increased number and variety of data sources that
generate large quantities of data




Sensors (e.g. location, acoustical, …)
Web 2.0 (e.g. twitter, wikis, … )
Web clicks
Realization that data was “too valuable” to delete
0
0
1
0

0
1
1
0
0
0
0
1
0
1
1
1
0
1
0
0
1
0
0
1
0
1
1
1
1
0
0
1
1
0
0
1
0
1
1
1
1
1
1
1
1
0
0
1
0
Dramatic decline in the cost of hardware, especially storage

If storage was still $100/GB there would be no big data revolution
underway
4
Old
guard
Use a parallel
database system
eBay – 10PB on 256 nodes
Young
turks
Use a NoSQL system
Facebook - 20PB on 2700 nodes
Bing – 150PB on 40K nodes
5
NOSQL
What’s in the name...
6
NO to SQL
It’s not about saying that
SQL should never be used,
or that SQL is dead...
7
NOT Only SQL
It’s about recognizing
that for some problems
other storage solutions
are better suited!
8

More data model flexibility



Relaxed consistency models such as
eventual consistency



Willing to trade consistency for availability
Low upfront software costs
Never learned anything but C/Java in school


JSON as a data model
No “schema first” requirement
Hate declarative languages like SQL
Faster time to insight from data acquisition
9
SQL:
Data
Arrives
Cleanse
the data
3
1
Transform
the data
Load
the data
5
4
Derive a
schema
SQL
Queries
RDBMS
6
2
NoSQL:
NOSQL
System
Data
Arrives
Application
Program
2
1




No cleansing!
No ETL!
No load!
Analyze data where it lands!
10

Key/Value Stores





Examples: MongoDB, CouchBase, Cassandra,
Windows Azure, …
Flexible data model such as JSON
Records “sharded” across nodes in a cluster by
hashing on key
Single record retrievals based on key
Hadoop



Scalable fault tolerant framework for storing and
processing MASSIVE data sets
Typically no data model
Records stored in distributed file system
11
Structured
Relational DB Systems
Structured data w/ known schema
ACID
Transactions
SQL
Rigid Consistency Model
ETL
Longer time to insight
Maturity, stability, efficiency
&
Unstructured
NoSQL Systems
(Un)(Semi)structured data w/o schema
No ACID
No transactions
No SQL
Eventual consistency
No ETL
Faster time to insight
Flexibility
12



I believe the world has truly
changed
Relational DB systems no
longer the only game in town
As SQL “guys” we must accept
this new reality and understand
how best to deploy technologies
like Hadoop



This is NOT a paradigm shift
RDBMS will continue to
dominate transaction
processing and ALL small to
medium sized data
warehouses
But many businesses will end
up with data in both universes
This talk will focus on Hadoop + its ecosystem
13
2006
2003
Hadoop
MR/GFS

Massive amounts of click stream data that had to be
stored and analyzed
Requirements:



Store
Process
Store
HDFS + MapReduce
Scalable toHadoop
PBs and =
1000s
of nodes
Highly fault tolerant
Simple to program against
Process
GFS + MapReduce
distributed $
fault-tolerant
“new” programming
paradigm
14
Scalability and a
high degree of
fault tolerance
Ability to quickly
analyze massive
collections of
records without
forcing data to
first be modeled,
cleansed, and
loaded
Low, up front
software and
hardware costs
Easy to use
programming
paradigm for writing
and executing
analysis programs
that scale to 1000s
of nodes and PBs of
data
Think data
warehousing
for Big Data



ETL
BI
Reporting Tools
RDBMS
Hive & Pig
Map/
Reduce
HBase
HDFS
Sqoop
Avro (Serialization)

HDFS – distributed, fault tolerant file system
MapReduce – framework for writing/executing distributed, fault
tolerant algorithms
Hive & Pig – SQL-like declarative languages
Sqoop – package for moving data between HDFS and relational
DB systems
+ Others…
Zookeeper

16
(Visually…)
3
Hive & Pig
2 Map/
Reduce
4
Sqoop
Relational
Databases
5
HDFS
1
17


Underpinnings of the entire
Hadoop ecosystem
HDFS design goals:






Scalable to 1000s of nodes
Assume failures (hardware and
software) are common
Targeted towards small numbers
of very large files
Write once, read multiple times
Traditional hierarchical file
organization of directories and
files
Highly portable
Hive & Pig
Map/
Reduce
Sqoop
HDFS
18
Large File
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
1100101010011100101010011100101010011100101010011100110010101001110010101001110010101001110010101001110010101001
…
6440MB
Let’s color-code them
Block
1
Block
2
Block
3
Block
4
Block
5
Block
6
64MB
64MB
64MB
64MB
64MB
64MB
e.g., Block Size = 64MB
…
Block
100
Block
101
64MB
40MB
Files are composed of set of blocks
• Typically 64MB in size
• Each block is stored as a separate file in
the local file system (e.g. NTFS)
19
Block
1
Block
2
Block
3
Block
1
Block
3
Block
2
Block
2
Block
3
Block
1
Node 1
Node 2
Node 3
Node 4
Node 5
e.g., Replication factor = 3

Default placement policy:



First copy is written to the node creating the file (write affinity)
Second copy is written to a data node within the same rack
(to minimize cross-rack network traffic)
Third copy is written to a data node in a different rack
(to tolerate switch failures)
20

NameNode – one instance per cluster

Responsible for filesystem metadata operations on cluster,
replication and locations of file blocks
Master
NameNode

Backup Node – responsible for backup of NameNode
CheckpointNode

or
BackupNode
(backups)
DataNodes – one instance on each node of the cluster


Responsible for storage of file blocks
Serving actual file data to client
DataNode
DataNode
DataNode
DataNode
Slaves
21
NameNode
BackupNode
namespace backups
(heartbeat, balancing, replication, etc.)
DataNode
DataNode
DataNode
DataNode
DataNode
nodes write to local disk
22
Giant File
110010101001
010100101010
011001010100
101010010101
001100101010
010101001010
100110010101
001010100101
node2, node 4}
3}
node4,
5}
{node2,
{node1, node3,
(based on “replication
factor”) (3 by default)
HDFS
Client
Name node tells client where to store each
block of the file
Client transfers block directly
to assigned data nodes
NameNode
BackupNode
and so on…
DataNode
DataNode
DataNode
DataNode
DataNode
23
Giant File
110010101001
010100101010
011001010100
101010010101
001100101010
010101001010
100110010101
001010100101
HDFS
Client
return locations
of blocks of file
NameNode
BackupNode
stream blocks from data nodes
DataNode
DataNode
DataNode
DataNode
DataNode
24

HDFS was designed with the expectation that
failures (both hardware and software) would
occur frequently
Failure types:





Disk errors and failures
DataNode failures
Switch/Rack failures
NameNode failures
Datacenter failures
DataNode
NameNode
25
NameNode
BackupNode
Blocks areNameNode
auto-replicated
on remaining
detects DataNode
loss
nodes to satisfy replication factor
DataNode
DataNode
DataNode
DataNode
DataNode
26
NameNode loss requires
manual intervention
NameNode
BackupNode
Automatic failover is
in the works
Not an epic failure, because you
have the BackupNode
DataNode
DataNode
DataNode
DataNode
DataNode
27
NameNode
BackupNode
Blocksdetects
are re-balanced
NameNode
new DataNode
and
is added
re-distributed
to cluster
DataNode
DataNode
DataNode
DataNode
DataNode
DataNode
28

Highly scalable



No use of mirroring or RAID.



1000s of nodes and massive (100s of TB) files
Large block sizes to maximize sequential I/O
performance
Why?
Reduce cost
Use one mechanism (triply replicated blocks) to deal
with a wide variety of failure types rather than multiple
different mechanisms
Negatives

Block locations and record placement is invisible to
higher level software
 Makes it impossible to employ many optimizations
successfully employed by parallel DB systems
29
(Visually…)
3
Hive & Pig
2 Map/
Reduce
4
Sqoop
Relational
Databases
5
HDFS
1
30


Programming framework (library and runtime) for
analyzing data sets stored in HDFS
MapReduce jobs are composed of two functions:
map()  reduce()
sub-divide &
conquer


combine & reduce
cardinality
User only writes the Map and Reduce functions
MR framework provides all the “glue” and coordinates
the execution of the Map and Reduce jobs on the
cluster.


Fault tolerant
Scalable
31
Essentially, it’s…
1.
Take a large problem and divide it into sub-problems
MAP
…
2.
Perform the same function on all sub-problems
REDUCE
DoWork()
3.
DoWork()
DoWork()
…
Combine the output from all sub-problems
…
Output
32
<keyi, valuei>
Mapper
DataNode
<keyA, valuea>
<keyB, valueb>
<keyC, valuec>
…
<keyA, list(valuea, valueb, valuec, …)>
Reducer
<keyi, valuei>
Mapper
<keyA, valuea>
<keyB, valueb>
<keyC, valuec>
…
DataNode
<keyi, valuei>
Mapper
<keyA, valuea>
<keyB, valueb>
<keyC, valuec>
…
Sort
and
group
by
key
<keyB, list(valuea, valueb, valuec, …)>
Reducer
Output
<keyC, list(valuea, valueb, valuec, …)>
DataNode
Reducer
<keyi, valuei>
Mapper
<keyA, valuea>
<keyB, valueb>
<keyC, valuec>
…
33
-
Coordinates all M/R tasks & events
Manages job queues and scheduling
Maintains and Controls TaskTrackers
Moves/restarts map/reduce tasks if needed
Uses “checkpointing” to combat single points
of failure
Master
hadoop-namenode
JobTracker
NameNode
MapReduce
Layer
HDFS
Layer
JobTracker controls and
heartbeats TaskTracker nodes
Execute individual
map and reduce
tasks as assigned by
JobTracker
(in
MapReduce
separate JVM)
Layer
HDFS
Layer
hadoopdatanode1
TaskTracker
hadoophadoopdatanode2Slaves
datanode3
TaskTracker
TaskTracker
hadoopdatanode4
TaskTracker
TaskTrackers store temp data
DataNode Temporary
DataNode
data stored toDataNode
local file system DataNode
34
Submit jobs to JobTracker
MR
Client
JobTracker
jobs get queued
map()’s are assigned to TaskTrackers
reduce phase
begins
(HDFS DataNode
locality
aware)
mappers spawned
in separate JVM
and execute
TaskTracker
TaskTracker
TaskTracker
TaskTracker
Mapper
Reducer
Mapper
Reducer
Mapper
Reducer
Mapper
Reducer
mappers store temp results
Temporary data stored to local file system
35
Get sum sales grouped by zipCode
4
54235
$75
7
10025
$60
2
53705
$30
1
02115
4
$15
0
8
DataNode2
54235
$75
5 7 53705
10025 $65
$60
3
54235 $22
10025 $95
44313
Mapper
$55
5
53705
$65
0
54235
$22
5
53705
$15
2
53705
$30
6
44313
$10
1
02115
$15
3
10025
$95
5
53705
6
44313
44313 6 $10
8
44313
$55
6
44313
$25
9
02115
$15
$15
9
02115
Group
By
54235
$75
54235
$22
10025
$60
10025
$95
44313
$55
53705
$65
One output
bucket per
reduce task
Mapper
DataNode1
Blocks
of the
Sales
file in
HDFS
DataNode3
(custId, zipCode, amount)
Group
By
53705
$30
53705
$15
02115
$15
02115
$15
44313
$10
44313
$25
$25
$15
Map tasks
36
Mapper
Reducer
$65
54235
$75
53705
$30
54235
$22
53705
$15
10025
$60
10025
$95
44313
$55
$30
53705
$15
02115
$15
44313
44313
$65
53705
$30
53705
$15
44313
$10
10025
$60
44313
$25
10025
$95
10025
$60
44313
$10
10025
$95
44313
$25
44313
$55
44313
$55
$65
53705
02115
Sort
53705
SUM
53705
$110
10025
$155
44313
$90
02115
$30
54235
$97
Reducer
Shuffle
53705
Mapper
53705
Sort
Reduce
tasks
SUM
Reducer
54235
$75
54235
$22
02115
$15
02115
$15
$15
$10
$25
Sort
SUM
02115
$15
54235
$75
02115
$15
54235
$22
38
Dataset A
Reducer 1
Dataset B
Reducer 2
Different join keys
Reducer N
Reducers perform the
actual join
Shuffling and sorting
over the network
Shuffling and Sorting
- Each mapper produces
the join key and the record
pairs
Mapper
1
Mapper
2
Mapper
3
Mapper
M+N
- Each mapper processes
one block (split)
HDFS stores data blocks
(Replicas are not shown)
39


Actual number of Map tasks M is generally made
much larger than the number of nodes used.
Why?

Helps deal with data skew and failure
Example:
Say M = 10,000 and
W = 100 (W is number of Map workers)
Each worker does (10,000 / 100) = 100 Map tasks
If it suffers from skew or fails the uncompleted work can
easily be shifted to another worker

Skew with Reducers is still a problem

Example: In a query = “get sales by zipcodes”,
some zipCodes (e.g. 10025) may have many more
sales records than others
40


Like HDFS, MapReduce framework designed
to be highly fault tolerant
Worker (Map or Reduce) failures




Detected by periodic Master pings
Map or Reduce jobs that fail are reset and then
given to a different node
If a node failure occurs after the Map job has
completed, the job is redone and all Reduce jobs
are notified
Master failure

If the master fails for any reason the entire
computation is redone
41



Highly fault tolerant
Relatively easy to write
“arbitrary” distributed
computations over very
large amounts of data
MR framework removes
burden of dealing with
failures from
programmer


Schema embedded in
application code
A lack of shared schema



Makes sharing data
between applications
difficult
Makes lots of DBMS
“goodies” such as indices,
integrity constraints, views,
… impossible
No declarative query
language
42
(Visually…)
3
Hive & Pig
2 Map/
Reduce
4
Sqoop
Relational
Databases
5
HDFS
1
43

and
reached a different conclusion
about the value of declarative languages like SQL
than Google

Facebook produced a
SQL-like language called
HIVE


Yahoo produced a slightly
more procedural language
PIG
Both use Hadoop MapReduce as a target
language for execution

Hive and Pig queries get compiled into a sequence of
MapReduce jobs
44
Consider two data sets:
UserVisits
Rankings
(
(
sourceIP STRING,
destURL STRING
visitDate DATE,
adRevenue FLOAT,
.. // fields omitted
pageURL STRING,
pageRank INT,
avgDuration INT
);
);
Query:
Find the sourceIP address
that generated the most adRevenue
along with its average pageRank
45
// Phase #1
// ------------------------------------------JobConf p1_job = base.getJobConf();
p1_job.setJobName(p1_job.getJobName() + ".Phase1");
Path p1_output = new Path(base.getOutputPath().toString() + "/phase1");
FileOutputFormat.setOutputPath(p1_job, p1_output);
package edu.brown.cs.mapreduce.benchmarks;
import java.util.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
import org.apache.hadoop.mapred.lib.*;
import org.apache.hadoop.fs.*;
import edu.brown.cs.mapreduce.BenchmarkBase;
//
// Make sure we have our properties
//
String required[] = { BenchmarkBase.PROPERTY_START_DATE,
BenchmarkBase.PROPERTY_STOP_DATE };
for (String req : required) {
if (!base.getOptions().containsKey(req)) {
System.err.println("ERROR: The property '" + req + "' is not set");
System.exit(1);
}
} // FOR
public class Benchmark3 extends Configured implements Tool {
public static String getTypeString(int type) {
if (type == 1) {
return ("UserVisits");
} else if (type == 2) {
return ("Rankings");
}
return ("INVALID");
}
/* (non-Javadoc)
* @see org.apache.hadoop.util.Tool#run(java.lang.String[])
*/
public int run(String[] args) throws Exception {
BenchmarkBase base = new BenchmarkBase(this.getConf(), this.getClass(), args);
Date startTime = new Date();
System.out.println("Job started: " + startTime);
1
p1_job.setInputFormat(base.getSequenceFile() ? SequenceFileInputFormat.class :
KeyValueTextInputFormat.class);
if (base.getSequenceFile()) p1_job.setOutputFormat(SequenceFileOutputFormat.class);
p1_job.setOutputKeyClass(Text.class);
p1_job.setOutputValueClass(Text.class);
p1_job.setMapperClass(base.getTupleData() ?
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase1.TupleWritableMap.class :
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase1.TextMap.class);
p1_job.setReducerClass(base.getTupleData() ?
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase1.TupleWritableReduce.class :
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase1.TextReduce.class);
p1_job.setCompressMapOutput(base.getCompress());
// Phase #2
// ------------------------------------------JobConf p2_job = base.getJobConf();
p2_job.setJobName(p2_job.getJobName() + ".Phase2");
p2_job.setInputFormat(base.getSequenceFile() ? SequenceFileInputFormat.class :
KeyValueTextInputFormat.class);
if (base.getSequenceFile()) p2_job.setOutputFormat(SequenceFileOutputFormat.class);
p2_job.setOutputKeyClass(Text.class);
p2_job.setOutputValueClass(Text.class);
p2_job.setMapperClass(IdentityMapper.class);
p2_job.setReducerClass(base.getTupleData() ?
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase2.TupleWritableReduce.class :
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase2.TextReduce.class);
p2_job.setCompressMapOutput(base.getCompress());
2
//
// Execute #1
//
base.runJob(p1_job);
//
// Execute #2
//
Path p2_output = new Path(base.getOutputPath().toString() + "/phase2");
FileOutputFormat.setOutputPath(p2_job, p2_output);
FileInputFormat.setInputPaths(p2_job, p1_output);
base.runJob(p2_job);
//
// Execute #3
//
Path p3_output = new Path(base.getOutputPath().toString() + "/phase3");
FileOutputFormat.setOutputPath(p3_job, p3_output);
FileInputFormat.setInputPaths(p3_job, p2_output);
base.runJob(p3_job);
// Phase #3
// ------------------------------------------JobConf p3_job = base.getJobConf();
p3_job.setJobName(p3_job.getJobName() + ".Phase3");
p3_job.setNumReduceTasks(1);
p3_job.setInputFormat(base.getSequenceFile() ? SequenceFileInputFormat.class :
KeyValueTextInputFormat.class);
p3_job.setOutputKeyClass(Text.class);
p3_job.setOutputValueClass(Text.class);
//p3_job.setMapperClass(Phase3Map.class);
p3_job.setMapperClass(IdentityMapper.class);
p3_job.setReducerClass(base.getTupleData() ?
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase3.TupleWritableReduce.class :
edu.brown.cs.mapreduce.benchmarks.benchmark3.phase3.TextReduce.class);
// There does need to be a combine if (base.getCombine()) base.runCombine();
return 0;
}
}
3
4
46
SELECT sourceIP, totalRevenue, avgPageRank
FROM
SELECT sourceIP, sum(adRevenue) as totalRevenue,
avg(pageRank)as avgPageRank
FROM Rankings as R, Uservisits as UV
WHERE R.pageURL = UV.destURL and UV.visitDate
between Date (‘2000-01-15’) and Date (‘2000-01-22’)
GROUP BY UV.sourceIP
ORDER BY totalRevenue DESC limit 1;
47
Fault tolerant system
Massive
Data Sets
Declarative
Queries
(leveraging Hadoop stack)
HIVE
HiveQL = Best Features(SQL) + MapReduce
48


Like a relational DBMS, data stored in tables
Richer column types than SQL


Primitive types: ints, floats, strings, date
Complex types: associative arrays, lists, structs
Example:
CREATE Table Employees
(
Name string,
Salary integer,
Children List <Struct <firstName: string, DOB:date>>
)
49


Like a parallel DBMS, Hive tables can be partitioned
Example data file:
Sales(custID, zipCode, date, amount)
partitioned by state
Hive DDL:
Create Table Sales(
custID INT,
zipCode STRING,
date DATE,
amount FLOAT)
Partitioned By
(state STRING)
Sales
custID zipCode …
custID zipCode …
201
12345 …
13
54321 …
105
12345 …
67
54321 …
933
12345 …
45
74321 …
Alabama
HDFS Directory
custID zipCode …
…
Alaska
78
99221 …
345
99221 …
821
99221 …
Wyoming
1 HDFS file per state
50
Sales(custID, zipCode, date, amount) partitioned by state
HDFS Directory
Sales
custID zipCode …
HDFS files
custID zipCode …
201
12345 …
13
54321 …
105
12345 …
67
54321 …
933
12345 …
45
74321 …
Alabama
custID zipCode …
…
Alaska
78
99221 …
345
99221 …
821
99221 …
Wyoming
Query 1: For the last 30 days obtain total sales by zipCode:
SELECT zipCode, sum(amount)
FROM Sales
WHERE getDate()-30 < date < getDate()
GROUP BY zipCode
Query will be executed
against all 50 partitions
of Sales
51
Sales(custID, zipCode, date, amount) partitioned by state
HDFS Directory
Sales
custID zipCode …
HDFS files
custID zipCode …
201
12345 …
13
54321 …
105
12345 …
67
54321 …
933
12345 …
45
74321 …
Alabama
Alaska
custID zipCode …
…
78
99221 …
345
99221 …
821
99221 …
Wyoming
Query 2: For the last 30 days obtain total sales by zipCode for Alabama:
SELECT zipCode, sum(amount)
FROM Sales
WHERE State = ‘Alabama’ and
getDate()-30 < date < getDate()
GROUP BY zipCode
52
Sales(custID, zipCode, date, amount) partitioned by state
HDFS Directory
Sales
custID zipCode …
HDFS files
custID zipCode …
201
12345 …
13
54321 …
105
12345 …
67
54321 …
933
12345 …
45
74321 …
Alabama
Alaska
custID zipCode …
…
78
99221 …
345
99221 …
821
99221 …
Wyoming
Query 3: For the last 30 days obtain total sales by congressional district
FROM
(
MAP zipcode using ‘python CD_mapper.py’ as (cd, amount)
FROM Sales
CLUSTER by cd
)
REDUCE(cd, amount) USING ‘python cd_sumsales.py’
53

Query Optimization



Heuristics
Limited statistics (file sizes only)
make cost-based QO essentially
impossible
Uses simple heuristics of pushing
selections below joins, early
column elimination
Output of QO is a DAG of
MapReduce jobs in Java

Optimizer
Query execution handled by
standard MR scheduler

Fine-grained fault tolerance
comes for free

Plans are… complicated

Can survive node/disk/switch
failures in the middle of a query
Plans are more complicated
than absolutely necessary since
both Map and Reduce jobs can
consume a single HDFS file as
input
54

Hardware


Cluster of 9 HP servers, dual CPU, quad core,
16GB memory, 4 SAS drives for data
Software

SQL Server PDW Version “next”


Windows Hadoop Version 0.20.203,
Hive Version 0.7.1



1 control node, 8 compute nodes
1 name node, 8 data nodes
Windows Server 2008
Test tables from TPC-H (SF 800)


lineitem: 612GB, 4.8B rows
orders: 140GB, 1.2B rows
55
Query 1: SELECT count(*) FROM lineitem
Query 2: SELECT max(l_quantity)
FROM lineitem
WHERE l_orderkey > 1000 and l_orderkey < 100000
GROUP BY l_linestatus
Secs.
1500
1000
Hive
PDW
500
0
Query 1
Query 2
56
Query 3: SELECT max(l_orderkey)
FROM orders, lineitem
where l_orderkey = o_orderkey
2 PDW cases:
Partitioning i)the
Hive tables
onpartitioned
the
PDW-U:
orders
on c_custkey
join attributes provideslineitem
no benefit,
partitioned on l_partkey
PDW-P:
orders
partitioned on o_orderkey
as there is noii) way
to control
where
Demonstrates the advantage
lineitem
HDFS places the blocks
of each partitioned on l_orderkey
that a parallel DBMS has w.r.t
partitioning tables in order to
minimize data movement
table
Secs.
4000
(here tables’ partitions are colocated)
3000
Hive
PDW-U
PDW-P
2000
1000
0
Hive
PDW-U
PDW-P
57
(Visually…)
3
Hive & Pig
2 Map/
Reduce
4
Sqoop
Relational
Databases
5
HDFS
1
58
(Reason #1)
Structured
(RDBMS)
Unstructured
(Hadoop)
Sqoop

Increasingly data first lands in the unstructured universe
MapReduce is an excellent big data ETL tool

Sqoop provides command line load utility

59
(Reason #2)
Unstructured
(Hadoop)
Structured
(RDBMS)
Sqoop


Some analyses are easier to do in a procedural language or a
language like HiveQL with MapReduce constructs
Sqoop provides:


As we will see the
performance of this is
not very good
Command line unload utility
Query capability for Map tasks to “pull” data from the
RDBMS using SQL
60
(Reason #3)
Structured
(RDBMS)
Unstructured
(Hadoop)
Sqoop


Some applications need data from both universes
Only option is unstructured universe as unstructured data
cannot be loaded into RDBMS
Again performance of
this is not very good

Use Sqoop unload utility or query capability in Map tasks
61
Map tasks wants the results of the query:
Q: SELECT a,b,c
FROMforT each
WHERE
X is different
Map P
task.
Map 1
Sqoop
X=0
Example, assume Cnt is
100 and
Each
map() must see a
3 Map
be used subsetX=33
Map
2 instances
Map 3 are todistinct
of the result
For MapSqoop
1
Sqoop
X=66
For Map 2
For Map 3
L=33
L=33
L=34
RDBMS
Step (2): Sqoop generates unique query Q’
Performance T
is bound toCnt
be
pretty bad as table T gets
scanned 4 times!
Step
(1): Sqoop
runs
In general,
withlibrary
M Map
SELECT
tasks,
table count(*)
T would be
FROM TMWHERE
P
scanned
+ 1 times!!!!!!
to obtain Cnt, the number of
tuples Q will return
for each Map task:
SELECT a,b,c
FROM T WHERE P
ORDER BY a,b,c
Limit L, Offset X
Step (3): Each of the 3 Map tasks runs its
query Q’
62
Structured Universe
(RDBMS)
Unstructured Universe
(Hadoop)
Enterprise Data Manager


Moving data is so 20th century!
Why not build a data management system that:



Can execute queries across both universes w/o moving data
unnecessarily
Has the expressive power of a language like HiveQL
I term such a system an Enterprise Data Manager
63


First to attempt to produce an
“Enterprise Data Manager”
Like Hive




Use HDFS for “unstructured” data
Uses MR framework as underpinnings of its query
engine for fault tolerance and scalability
Supports HiveQL-like query language
Unlike Hive


Employs a relational DBMS on every node
Implements a novel split query execution
paradigm
64
MapReduce SQL
Job
Query

Parser

Query
Optimizer
Catalogs


MapReduce Master

MapReduce
MapReduce
MapReduce
MapReduce
MapReduce
HDFS RDBMS
MapReduce
HDFS RDBMS
HDFS RDBMS
HDFS RDBMS
HDFS RDBMS
HDFS RDBMS
Relational tables are partitioned
using hash partitioning
“Unstructured” data lives in HDFS
SQL queries get compiled into set
of MapReduce jobs
Novel split execution paradigm is
employed in which the DBMS is
used as much as possible
Consider a join of tables A and B
65
ADDING
w/o
having
to load it
Improved
Scalability
Fault
Tolerance
Unstructured
Data
Ever getting
competitive performance
SQL Server PDW
is MUCH easier
than
Hadoop-based system
67
Parallel DB Systems
Computing
Model
Data Model
Hardware
configuration
Fault Tolerance
Key
Characteristics
Hadoop
-
Notion of transactions
Transaction is the unit of work
ACID enforced
-
Notion of jobs
Job is the unit of work
No concurrency control
-
Structured data with known
schema
Read/Write mode
-
Any data will fit in any format
(un)(semi)structured
Read/Only mode
-
Purchased as an appliance
-
“User assembled” from
commodity machines
-
Failures assumed to be rare
No query level fault tolerance
-
Failures assumed to be common
Simple yet efficient fault tolerance
-
Efficiency, optimizations,
fine-tuning
-
Scalability, flexibility
Relational Databases vs. Hadoop?
(what’s the future?)
Relational databases and Hadoop
are designed to meet different needs
69
RDBMS-only or Hadooponly is NOT going to be
the default
70
71




Avrilia Floratou and Nikhil Teletia
for the Hive and PDW numbers
Quentin Clark, Il-Sung Lee, Sam
Madden, Jeff Naughton, Jignesh
Patel, and Jennifer Widom for
their comments on earlier drafts
of this talk
The PASS organizers for inviting
me back
All of you for the nice reception
and all those over-the-top tweets
72
Download