HBase is an open source, distributed, versioned, non-relational database modeled after Google's BigTable. It is built on top of HDFS for storage, and provides BigTable-like capabilities for Hadoop. HBase provides fast random access and strong consistency for large amounts of unstructured and semi-structured data across commodity servers. It is tightly integrated with Hadoop's MapReduce for distributed processing of large data sets.
1. HBase
Amandeep Khurana
University of California, Santa Cruz
Twitter: @amansk
amansk@gmail.com
www.amandeepkhurana.com
Tuesday, August 17, 2010
2. How did it start?
• At Google
• Lots of semi structured data
• Commodity hardware
• Horizontal scalability
• Tight integration with MapReduce
2
Tuesday, August 17, 2010
3. Why NoSQL?
• RDBMS don’t scale
• Typically large monolithic systems
• Hard to shard
• Specialized hardware.. expensive!
• Buzzword!
3
Tuesday, August 17, 2010
4. Google BigTable
• Distributed multi level map
• Fault tolerant, persistent
• Scalable
• Runs on commodity hardware
• Self managing
• Large number of read/write ops
• Fast scans
4
Tuesday, August 17, 2010
5. HBase
• Open source BigTable
• HDFS as underlying DFS
• ZooKeeper as lock service
• Tight integration with Hadoop MapReduce
5
Tuesday, August 17, 2010
6. HBase
• Data model
• Architecture, implementation
• Regions, Region Servers etc
• API
• Current status and future direction
• Use cases
• How to think HBase (or NoSQL)?
6
Tuesday, August 17, 2010
7. Data Model
• Sparse, multi dimensional map
(row, column, timestamp) cell
• Column = Column Family:Column Qualifier
Columns
Fam1:Qual1
Rows
t1
AK v1
Timestamps
7
Tuesday, August 17, 2010
8. Data Model
• Sparse, multi dimensional map
(row, column, timestamp) cell
• Column = Column Family:Column Qualifier
Columns
Fam1:Qual1
Rows
t1
AK v1 t2
v2
Timestamps
t2>t1
7
Tuesday, August 17, 2010
9. Regions
• Region: Contiguous set of lexicographically
sorted rows
• hbase.hregion.max.filesize (default 256MB)
• Regions hosted by Region Servers
8
Tuesday, August 17, 2010
12. Regions and Splitting
row1
row256
row257
row400
row401
row600
9
Tuesday, August 17, 2010
13. System Structure
M
a
p Region Servers Master
R
e
d
u
c
e HDFS ZooKeeper
10
Tuesday, August 17, 2010
14. Master
• Region splitting
• Load balancing
• Metadata operations
• Multiple masters for failover
11
Tuesday, August 17, 2010
15. ZooKeeper
• Master election
• Locate -ROOT- region
• Region Server membership
12
Tuesday, August 17, 2010
16. Where is my row?
• 3 level hierarchical lookup scheme MyTable
.META.
MyRow
-ROOT-
ZooKeeper
13
Tuesday, August 17, 2010
17. Where is my row?
• 3 level hierarchical lookup scheme MyTable
.META.
MyRow
-ROOT-
ZooKeeper
13
Tuesday, August 17, 2010
18. Where is my row?
• 3 level hierarchical lookup scheme MyTable
.META.
MyRow
-ROOT-
ZooKeeper
Row per META region
13
Tuesday, August 17, 2010
19. Where is my row?
• 3 level hierarchical lookup scheme MyTable
.META.
MyRow
-ROOT-
ZooKeeper
Row per META region
Row per table region
13
Tuesday, August 17, 2010
20. Where is my row?
• 3 level hierarchical lookup scheme MyTable
.META.
MyRow
-ROOT-
ZooKeeper
Row per META region
Row per table region
13
Tuesday, August 17, 2010
21. Region
Memstore
HLog
(Append only
WAL on HDFS)
HFile HFile
(on HDFS) (on HDFS)
(Sequence File)
(one per RS)
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
22. Region
Write
Memstore
HLog
(Append only
WAL on HDFS)
HFile HFile
(on HDFS) (on HDFS)
(Sequence File)
(one per RS)
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
23. Region
Memstore
HLog
(Append only
WAL on HDFS)
HFile HFile
(on HDFS) (on HDFS)
(Sequence File)
(one per RS)
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
24. Region
Memstore Flush
HLog
(Append only Small
WAL on HDFS)
HFile HFile
(Sequence File)
(on HDFS) (on HDFS) HFile
(one per RS)
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
25. Region
Memstore
HLog
(Append only Small
WAL on HDFS)
HFile HFile
(Sequence File)
(on HDFS) (on HDFS) HFile
(one per RS)
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
26. Region
Memstore
HLog
(Append only Small
WAL on HDFS)
HFile HFile
(Sequence File)
(on HDFS) (on HDFS) HFile
(one per RS) Compaction
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
27. Region
Memstore
HLog
(Append only
WAL on HDFS)
(Sequence File)
(one per RS) Compaction
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
28. Region
Memstore
HLog
(Append only
WAL on HDFS)
HFile
(on HDFS)
(Sequence File)
(one per RS)
Region
HFile: Immutable sorted map (byte[] byte[])
(row, column, timestamp) cell value
14
Tuesday, August 17, 2010
29. Region
Memstore
HLog
(Append only
WAL on HDFS)
HFile HFile HFile
(on HDFS) (on HDFS) (on HDFS)
(Sequence File)
(one per RS)
Region
15
Tuesday, August 17, 2010
30. Region
Read
Memstore
HLog
(Append only
WAL on HDFS)
HFile HFile HFile
(on HDFS) (on HDFS) (on HDFS)
(Sequence File)
(one per RS)
Region
15
Tuesday, August 17, 2010
32. Java API
• Get
• Put
• Delete
• Scan
• IncrementColumnValue
• TableInputFormat - MapReduce Source
• TableOutputFormat - MapReduce Sink
17
Tuesday, August 17, 2010
33. Other Features
• Compression
• In memory column families
• Multiple masters
• Rolling restart
• Bloom filters
• Efficient bulk loads
• Source and sink for Hive, Pig, Cascading
18
Tuesday, August 17, 2010
34. Things being worked on
• Master rewrite
• Move more stuff into ZooKeeper
• Column family based access control
• Inter cluster replication (managed by ZK)
• Store Lucene indexes (HBasene)
19
Tuesday, August 17, 2010
36. HBase @ SU*
• Backend for su.pr
• Real time serving + MR analytics (separate clusters)
• 50% cascading, 50% java MR
• Prod cluster (~20 nodes) serves 20k requests/sec
• All new features are backed by HBase
• Hardware: 2xi7, 24GB RAM, 4x1TB
*Source: Personal communication with
21
J-D Cryans, StumbleUpon
Tuesday, August 17, 2010
37. HBase @ Mozilla*
• Socorro - crash reporting system
• Catch, process and present crash info for Firefox, Thunderbird,
Fennec, Camino, Seamonkey
• 1.5m crash reports/day
• Earlier: NFS, PostgreSQL
• 17 node production cluster
• Dual Quad Core + 24GB RAM + 4x1TB
• Some user facing reports still served by PostgreSQL.
Being ported to HBase in next Socorro version
*Source: http://blog.mozilla.com/webdev/2010/07/26/
22
moving-socorro-to-hbase/
Tuesday, August 17, 2010
38. Data Integration*
• Multiple heterogenous data sources
• Notion of connected data
• Think RDF
• Graph connecting data elements across
systems
• Store in HBase, build transitive closures
• Pattern mining
*Source: ClouDFuse - Scalable data integration in the
23
cloud, MS Project, Amandeep Khurana, UC Santa Cruz
Tuesday, August 17, 2010
39. HBase @ Trend Micro*
• Store threat information - Smart Protection
Network
• Open source cloud computing initiative -
TCloud
• Primarily run off EC2
*Source: https://hbase.s3.amazonaws.com/hbase/HBase-
24
Trend-HUG10.pdf
Tuesday, August 17, 2010
40. HBase @ Yahoo*
• Content optimization
• Meta-data about content stored in HBase
• Used for extracting item features
• Used in conjunction with PNUTS, Hadoop
• Process 100s of GB in each run
*Source: http://www.slideshare.net/ydn/7-online-
25
contentoptimizationhadoopsummit2010
Tuesday, August 17, 2010
41. HBase @ Twitter*
• 7TB/day incoming data, increasing
• Analytics
• People search
• Building new solutions on HBase
• Part of a much larger scheme of things
• Scribe, Crane, Pig, MySQL, Cassandra, Oink,
Elephant Bird, Birdbrain, Hadoop
*Sources: http://www.slideshare.net/kevinweil/nosql-at-
twitter-nosql-eu-2010
http://www.slideshare.net/ydn/3-hadoop-
pigattwitterhadoopsummit2010 26
Tuesday, August 17, 2010
44. HBase v/s RDBMS
• Neither solves all problems
• It’s really a wrong comparison
• But puts things in context
29
Tuesday, August 17, 2010
45. HBase v/s RDBMS
HBase RDBMS
Column oriented Row oriented (mostly)
Flexible schema, add columns on the
Fixed schema
fly
Good with sparse tables Not optimized for sparse tables
No query language SQL
Wide tables Narrow tables
Optimized for joins (small, fast ones
Joins using MR - not optimized
too!)
Tight integration with MR Not really...
30
Tuesday, August 17, 2010
46. HBase v/s RDBMS
HBase RDBMS
De-normalize your data Normalize as you can
Horizontal scalability. Just add
Hard to shard and scale
hardware
Consistent Consistent
No transactions Transactional
Good for semi structured data as well
Good for structured data
as structured data
31
Tuesday, August 17, 2010
48. HBase v/s RDBMS
Rule:You probably don’t need HBase if your
data can easily fit and be processed on a single
RDBMS box.
32
Tuesday, August 17, 2010
49. HBase v/s RDBMS
Rule:You probably don’t need HBase if your
data can easily fit and be processed on a single
RDBMS box.
But then, you are at Hadoop Day, so it probably
can’t!
32
Tuesday, August 17, 2010