Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 36 ยท Architecture and Data Model

Regions, Splits and the Meta Table

Understand how HBase divides tables into regions by row-key range, how automatic splits, pre-splitting and merging work, and how hbase:meta finds a region.

A table in HBase can be enormous, but a server can only handle so much. HBase solves this by cutting every table into regions: contiguous, non-overlapping ranges of row keys. Each region is served by exactly one RegionServer at a time. Regions are the unit of distribution, load balancing and recovery, so understanding them explains a large part of HBase performance.

What a region is

A region covers [startKey, endKey): the start key is included and the end key is excluded. A new table begins with one region that spans everything (start key empty, end key empty). As data grows, regions split. A table with three regions might look like this:

Region Start key End key
1 (empty, from the beginning) g
2 g p
3 p (empty, to the end)

Every row belongs to exactly one region, and the sorted order of rows is what makes the ranges meaningful. Region names combine the table name, start key, a creation timestamp and an encoded hash, for example users,g,1699999999999.8f3c..... Each region also appears as a directory in HDFS, with one subfolder per column family.

Automatic splitting

A region splits when one of its stores grows past a threshold. The default policy in HBase 2.x is SteppingSplitPolicy: for a table with few regions it splits early (at about twice the memstore flush size, around 256 MB), and as the number of regions per server grows, the threshold rises toward hbase.hregion.max.filesize (10 GB by default). The split point is the middle key of the largest HFile.

Splitting is cheap at first: the two daughter regions are created as references to the parent's files (reference files), and real file copying happens later during compaction. The parent goes offline, the daughters come online, and the Master updates hbase:meta.

Because splitting follows the data, a monotonically increasing key (like a timestamp as the first part of the row key) causes a classic problem called hotspotting: all new writes land in the last region, so one server does all the work while the rest idle. The Schema Design chapter of the HBase track shows how to avoid that with salting and other patterns.

Java Stand-in: regions split when they get too big

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Pre-splitting

Starting with one region has a cost: until the first split, every write goes to a single server. For a table you know will be big, pre-split it at creation by giving explicit split points. Writes then spread across many servers from the first minute, and a bulk load does not start with a slow single-region phase.

Terminal
create 'events', 'd', SPLITS => ['2', '4', '6', '8']
create 'events2', 'd', {NUMREGIONS => 16, SPLITALGO => 'HexStringSplit'}

Both lines are read-only here. The first makes five regions with explicit keys; the second asks HBase to compute 16 evenly spaced hex-string boundaries (good when keys start with a hex hash). Choose boundaries that match the real distribution of your keys, or some regions will stay empty.

Java Stand-in: computing hex split points

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Merging and moving

Regions can also be merged (two adjacent small regions become one) with the merge_region shell command or an admin call; this is useful after heavy deletes or TTL expiry leaves many tiny regions. The balancer moves regions between servers to even the load; a move briefly takes the region offline while it closes on one server and opens on another. Manual move, split and merge_region commands exist, but let the automatic mechanisms work unless you have a measured reason.

The hbase:meta table

How does a client know which region holds a row key? From a special system table called hbase:meta. It has one row per region. The row key is the region name (table, start key, timestamp), and its info family holds the region's boundaries (info:regioninfo), the hosting server (info:server) and a start code. Because meta is sorted by region name, finding the region for a row is a single "last entry less than or equal to this key" lookup. Meta itself is served by a single region that never splits (the location is stored in ZooKeeper). Clients cache what they learn from it, so meta is read rarely.

Terminal
scan 'hbase:meta', {COLUMNS => ['info:server'], LIMIT => 3}

That command (read-only here) lists region names with the server hosting each; outputs vary per cluster.

The final stand-in reproduces the meta lookup: a sorted map from region start key to server, queried with floorEntry, exactly how a row finds its home.

Java Stand-in: a meta table lookup

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with IO.readln() or a Scanner), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What range does a region cover?

    Regions are contiguous row ranges, start inclusive and end exclusive.
  2. 2. Why pre-split a large new table?

    A new table starts with one region; pre-splitting spreads load across servers immediately.
  3. 3. Writes with a steadily increasing timestamp as the row-key prefix cause...

    New keys always sort at the end, so one region and one server absorb all the writes.
  4. 4. What does hbase:meta store?

    Meta maps regions to servers, which is how clients locate rows.
  5. 5. How do daughter regions initially hold data after a split?

    Reference files make the split fast; physical rewriting happens later in compaction.

Summary

  • Tables are cut into regions, contiguous key ranges [start, end), each served by one RegionServer.
  • Regions split automatically as they grow; you can pre-split for even early load.
  • Monotonic row keys create hotspots because new data always lands in the last region.
  • Regions can be merged or moved by the Master and balancer.
  • hbase:meta maps regions to servers; clients cache its answers.

Next: The Write Path: WAL, MemStore and HFiles