2012-05-07 15:22:55 +00:00
|
|
|
# HanoiDB Ordered Key/Value Storage
|
2012-01-07 16:54:35 +00:00
|
|
|
|
2012-05-07 15:22:55 +00:00
|
|
|
HanoiDB implements an ordered key/value storage engine, implemented
|
2012-04-26 15:12:37 +00:00
|
|
|
using "doubling sizes" persistent ordered sets of key/value pairs,
|
|
|
|
much like LevelDB.
|
2012-01-07 16:54:35 +00:00
|
|
|
|
|
|
|
Here's the bullet list:
|
2012-01-05 23:02:00 +00:00
|
|
|
|
2012-05-07 15:22:55 +00:00
|
|
|
- Insert, Delete and Read all have worst case *O*(log<sub>2</sub>(*N*)) latency.
|
2012-04-26 15:12:37 +00:00
|
|
|
- Incremental space reclaimation: The cost of evicting stale key/values
|
|
|
|
is amortized into insertion
|
2012-04-24 14:37:45 +00:00
|
|
|
- you don't need a separate eviction thread to keep memory use low
|
|
|
|
- you don't need to schedule merges to happen at off-peak hours
|
|
|
|
- Operations-friendly "append-only" storage
|
|
|
|
- allows you to backup live system
|
|
|
|
- crash-recovery is very fast and the logic is straight forward
|
2012-04-28 16:42:04 +00:00
|
|
|
- All data subject to CRC32 checksums
|
2012-04-24 14:37:45 +00:00
|
|
|
- Supports efficient range queries
|
2012-04-27 10:09:19 +00:00
|
|
|
- Riak secondary indexing
|
|
|
|
- Fast key and bucket listing
|
2012-04-24 14:37:45 +00:00
|
|
|
- Uses bloom filters to avoid unnecessary lookups on disk
|
|
|
|
- Efficient resource utilization
|
|
|
|
- Doesn't store all keys in memory
|
|
|
|
- Uses a modest number of file descriptors proportional to the number of levels
|
|
|
|
- IO is generally balanced between random and sequential
|
|
|
|
- Low CPU overhead
|
|
|
|
- ~2000 lines of pure Erlang code in src/*.erl
|
|
|
|
|
2012-05-07 15:22:55 +00:00
|
|
|
HanoiDB is developed by Trifork, a Riak expert solutions provider. You're most
|
2012-04-26 15:12:37 +00:00
|
|
|
welcome to contact us if you want help optimizing your Riak setup.
|
|
|
|
|
2012-04-28 16:42:04 +00:00
|
|
|
### Configuration options
|
|
|
|
|
2012-05-07 15:22:55 +00:00
|
|
|
Put these values in your `app.config` in the `hanoidb` section
|
2012-04-28 16:42:04 +00:00
|
|
|
|
|
|
|
```erlang
|
2012-05-07 15:22:55 +00:00
|
|
|
{hanoidb, [
|
|
|
|
{data_root, "./data/hanoidb"},
|
|
|
|
|
|
|
|
%% Enable/disable on-disk compression.
|
|
|
|
%%
|
|
|
|
{compress, none | gzip},
|
|
|
|
|
|
|
|
%% Sync strategy `none' only syncs every time the
|
|
|
|
%% nursery runs full, which is currently hard coded
|
|
|
|
%% to be evert 256 inserts or deletes.
|
|
|
|
%%
|
|
|
|
%% Sync strategy `sync' will sync the nursery log
|
|
|
|
%% for every insert or delete operation.
|
|
|
|
%%
|
2012-04-28 16:42:04 +00:00
|
|
|
{sync_strategy, none | sync | {seconds, N}},
|
2012-05-07 15:22:55 +00:00
|
|
|
|
|
|
|
%% The page size is a minimum page size, when a page fills
|
|
|
|
%% up to beyond this size, it is written to disk.
|
|
|
|
%% Compression applies to such units of page size.
|
|
|
|
%%
|
2012-05-01 14:27:06 +00:00
|
|
|
{page_size, 8192},
|
2012-05-07 15:22:55 +00:00
|
|
|
|
|
|
|
%% Read/write buffer sizes apply to merge processes.
|
|
|
|
%% A merge process has two read buffers and a write
|
|
|
|
%% buffer, and there is a merge process *per level* in
|
|
|
|
%% the database.
|
|
|
|
%%
|
2012-05-01 14:27:06 +00:00
|
|
|
{write_buffer_size, 524288}, % 512kB
|
|
|
|
{read_buffer_size, 524288}, % 512kB
|
|
|
|
|
|
|
|
%% The merge strategy is one of `fast' or `predictable'.
|
|
|
|
%% Both have same log2(N) worst case, but `fast' is
|
|
|
|
%% sometimes faster; yielding latency fluctuations.
|
|
|
|
%%
|
|
|
|
{merge_strategy, fast | predictable}
|
2012-04-28 16:42:04 +00:00
|
|
|
]},
|
|
|
|
```
|
|
|
|
|
2012-05-07 15:22:55 +00:00
|
|
|
### How to deploy HanoiDB as a Riak/KV backend
|
2012-04-24 14:37:45 +00:00
|
|
|
|
|
|
|
This storage engine can function as an alternative backend for Basho's Riak/KV.
|
|
|
|
|
2012-05-07 15:22:55 +00:00
|
|
|
You can deploy `hanoidb` into a Riak devrel cluster using the `enable-hanoidb`
|
2012-04-24 14:37:45 +00:00
|
|
|
script. Clone the `riak` repo, change your working directory to it, and then
|
2012-05-07 15:22:55 +00:00
|
|
|
execute the `enable-hanoidb` script. It adds `hanoidb` as a dependency, runs `make
|
2012-04-24 14:37:45 +00:00
|
|
|
all devrel`, and then modifies the configuration settings of the resulting dev
|
2012-05-07 15:22:55 +00:00
|
|
|
nodes to use the hanoidb storage backend.
|
2012-01-05 23:02:00 +00:00
|
|
|
|
2012-04-15 14:35:39 +00:00
|
|
|
1. `git clone git://github.com/basho/riak.git`
|
2012-05-07 15:22:55 +00:00
|
|
|
1. `mkdir riak/deps`
|
2012-04-15 14:35:39 +00:00
|
|
|
1. `cd riak/deps`
|
2012-05-07 15:22:55 +00:00
|
|
|
1. `git clone git://github.com/basho/hanoidb.git`
|
2012-04-15 14:35:39 +00:00
|
|
|
1. `cd ..`
|
2012-05-07 15:22:55 +00:00
|
|
|
1. `./deps/hanoidb/enable-hanoidb`
|