NAME
ShardedKV::Continuum::StaticMapping - A continuum strategy based on a simple "significant bits" static mapping
VERSION
version 0.16
SYNOPSIS
use ShardedKV;
use ShardedKV::Continuum::StaticMapping;
my $skv = ShardedKV->new(
continuum => ShardedKV::Continuum::StaticMapping->new(
num_significant_bits => 10, # 2**10 == up to 1024 tables/shards
from => [
[0, 255, "shard1"],
[256, 511, "shard2"],
[512, 767, "shard3"],
[768, 1023, "shard4"],
], FIXME!?
),
storages => {...},
);
If you ever wanted to add shards to a cluster that uses StaticMapping, you can't (currently) use "extend" to add more shards, you have to do something like this:
# given the above example ShardedKV and StaticMapping:
my $cont = $skv->continuum;
# Let's split shard2 into shard2 and shard2-1
my $new_cont_spec = [
[0, 255, "shard1"],
[256, 383, "shard2"],
[384, 511, "shard2-1"],
[512, 767, "shard3"],
[768, 1023, "shard4"],
];
my $migration_cont = ShardedKV::Continuum::StaticMapping->new(
num_significant_bits => $cont->num_significant_bits,
from => $new_cont_spec,
);
$skv->begin_migration($migration_cont);
... passive or active migration taking place from shard2 to shard2-1...
$skv->end_migration();
DESCRIPTION
A sharding strategy that skips the consistent hashing step and simply uses the first N bits of the key to decide which shard the key falls in.
Do not use this sharding strategy unless your key space is naturally evenly populated. This is generally only true if you use some sort of randomly generated key WHOSE RANDOMNESS YOU CAN RELY ON. Do realize that if an untrusted client or component has the ability to choose its own key, then this sharding strategy opens up a denial of service attack vector by defeating your sharding altogether.
If in doubt, use ShardedKV::Continuum::Ketama instead.
SEE ALSO
AUTHORS
Steffen Mueller <smueller@cpan.org>
Nick Perez <nperez@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Steffen Mueller.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.