Apache HBase
- Problem solved: real-time random reads and writes on tables of billions of rows, where HDFS and MapReduce only do batch processing.
- Era: first code posted on February 27, 2007 (Hadoop subproject), Apache top-level project on April 21, 2010, version 1.0 on February 24, 2015. Model: Bigtable (Google, 2006).
- Created by: Mike Cafarella (first code), Jim Kellerman, then the company Powerset; Michael Stack first Apache Vice President.
- Category: distributed wide-column database on Hadoop.
Historical context
In 2006, Google published the Bigtable paper. The system, designed, implemented and deployed over two and a half years, stores structured data at the scale of "petabytes of data across thousands of commodity servers" and serves more than sixty products (Google Analytics, Google Earth, Orkut...). It is the third floor of the Google stack, on top of GFS and MapReduce.
Hadoop had reproduced GFS and MapReduce, but not Bigtable: the ecosystem lacked "random, realtime read/write access" (the current promise of the HBase site) on top of HDFS. On February 27, 2007, Mike Cafarella, already co-author of Nutch, opened ticket HADOOP-1045: "I've written some code for HBase, a BigTable-like file store. It's not perfect, but it's ready for other people to play with". Jim Kellerman took the code over through successive patches, committed on April 3, 2007.
According to Yahoo! (2010), HBase was "originally developed at Powerset", a company that had by then become a department of Microsoft. The project grew as a Hadoop subproject, then on April 21, 2010 the ASF board made it a top-level project, with Michael Stack as Vice President.
The breakthrough came in November 2010: Facebook built its new messaging system on HBase. It had to absorb more than 15 billion messages and 120 billion chat messages per month. Facebook tested MySQL, Cassandra (which it had itself created) and others, and chose HBase for its simpler consistency model. In 2015, HBase 1.0 capped "7 years of development", with Apple, Pinterest, Salesforce and Yahoo! among its users.
Key idea
A Bigtable is "a sparse, distributed, persistent multi-dimensional sorted map": a big table sorted by row key, where each value is addressed by (row, column, timestamp). Sorting by key lets the table be split into contiguous ranges spread across the cluster, and keeps neighboring rows together (Google reverses URL host names to group the pages of one site). Every read or write on a single row is atomic, but Bigtable has no "general transactions across row keys"; HBase has no typed columns, no secondary indexes and no advanced query language. The HBase guide says it: it is "more a "Data Store" than "Data Base"".
How it works
HBase mirrors the Bigtable architecture, piece by piece:
| Bigtable (Google) | HBase |
|---|---|
| tablet (row range) | region |
| tablet server | RegionServer |
| memtable | MemStore |
| SSTable | HFile (StoreFile) |
| Chubby (locks) | ZooKeeper |
| GFS | HDFS |
- Writes: each change is first logged to a WAL (Write Ahead Log) stored in files, then kept in memory in the MemStore. When it is full, it is written to disk as a new file; files are later merged by compaction.
- Failure: if a RegionServer dies before flushing its MemStore, the WAL is replayed.
- Distribution: a table is split into regions, "automatically split and re-distributed as your data grows". Each column family has its own storage (Store).
- Location: the
hbase:metatable lists all regions, and its location is stored in ZooKeeper.
Example from the quick start guide (HBase shell):
create 'test', 'cf'
put 'test', 'row1', 'cf:a', 'value1'
get 'test', 'row1'
scan 'test'
By the numbers
| Figure | Context | Source |
|---|---|---|
| 388 clusters, ~24,500 servers | Bigtable deployment at Google in August 2006 | Bigtable paper |
| Over 1.2 million req/s | Across 14 Bigtable clusters totaling 8,069 servers (2006) | Bigtable paper |
| 800 TB | Google's "Crawl" table, before compression (2006) | Bigtable paper |
| 51 kB | hbase.tar.gz archive of the first code, February 27, 2007 | Jira HADOOP-1045 |
| 15 and 120 billion | Messages and chat messages per month at Facebook (November 2010) | Facebook Engineering |
| Over 500 million | People to serve from day one of Facebook Messages (2011) | SIGMOD 2011 paper |
| Over 1,500 | Changes in HBase 1.0 since 0.98.0 (February 2015) | ASF 1.0 announcement |
| 5 DataNodes | Recommended HDFS minimum under HBase (replication factor 3) | HBase guide |
Milestones
- 2006: Google publishes "Bigtable: A Distributed Storage System for Structured Data" (OSDI).
- February 27, 2007: Mike Cafarella posts the first HBase code (HADOOP-1045).
- April 3, 2007: the code, reworked by Jim Kellerman, is committed to Hadoop.
- April 21, 2010: the ASF board creates the Apache HBase project, Michael Stack Vice President.
- November 15, 2010: Facebook unveils its messaging system built on HBase.
- 2011: paper "Apache Hadoop Goes Realtime at Facebook" (SIGMOD).
- February 24, 2015: HBase 1.0, with region replicas for read availability.
Did you know?
- The first HBase code fit in a 51 kB archive.
- The 2010 board resolution creating HBase opens with a recital about software "related to data serialization", before mentioning, further down, a "distributed database".
- Facebook had open sourced Cassandra in 2008, but chose HBase for Messages: "Cassandra's eventual consistency model" was hard to reconcile with the new messaging system.
- The HBase guide advises against it for "a few thousand/million rows": a traditional RDBMS would do better.
Strengths and limitations
| Strengths | Limitations |
|---|---|
| Fast random reads/writes on billions of rows | No SQL, no secondary indexes, no column types |
| Strongly consistent reads and writes | Atomicity limited to one row |
| Automatic sharding into regions | Depends on HDFS and ZooKeeper: heavy to operate, at least 5 DataNodes |
| Integrated with Hadoop (HDFS, MapReduce) | Poor fit for small volumes |
What came next
- Cassandra, created at Facebook and open sourced in 2008, combines the Bigtable data model with Dynamo-style distribution, masterless and eventually consistent: the other path, which Facebook did not pick for Messages.
- ZooKeeper remains HBase's coordination piece (location of
hbase:meta). - Druid targets another need, real-time analytics on events, rather than reading one row by its key.
- Yahoo!'s HDFS paper (2010) lists HBase as the "Column-oriented table service" of the Hadoop ecosystem.
Sources
raw-data/apache/hbase/hbase.md; Cassandra:raw-data/apache/cassandra/- Chang et al., "Bigtable: A Distributed Storage System for Structured Data", OSDI 2006: https://static.googleusercontent.com/media/research.google.com/en//archive/bigtable-osdi06.pdf
- Jira HADOOP-1045 "Code for HBase": https://issues.apache.org/jira/browse/HADOOP-1045
- Shvachko et al., "The Hadoop Distributed File System", MSST 2010: https://pages.cs.wisc.edu/~akella/CS838/F15/838-CloudPapers/hdfs.pdf
- ASF board, April 21, 2010: https://www.apache.org/foundation/board/minutes/2010/board_minutes_2010_04_21.html
- Kannan Muthukkaruppan, "The Underlying Technology of Messages", November 15, 2010: https://engineering.fb.com/2010/11/15/core-infra/the-underlying-technology-of-messages/
- Borthakur et al., "Apache Hadoop Goes Realtime at Facebook", SIGMOD 2011: http://borthakur.com/ftp/RealtimeHadoopSigmod2011.pdf
- ASF HBase 1.0 announcement: https://news.apache.org/foundation/entry/the_apache_software_foundation_announces72
- https://hbase.apache.org/ ; https://hbase.apache.org/book.html
- Find a primary source for Powerset's exact role (and the date of its acquisition by Microsoft) beyond the HDFS paper sentence.
- Primary dates for HBase 2.0 and Apache Phoenix (SQL layer on top of HBase).
- Check whether Facebook later moved Messages off HBase.