Crates.io | location_based_sharding |
lib.rs | location_based_sharding |
version | 0.1.4 |
source | src |
created_at | 2022-01-23 08:34:52.936329 |
updated_at | 2022-02-06 09:59:23.845786 |
description | Right sized sharding algorithm |
homepage | |
repository | |
max_upload_size | |
id | 519545 |
size | 39,805 |
Based off Tinder own location based sharding algorithm, the algorithm will create shards based off of the "heat" of users in a particular location. This flexible sharding schema allows less dense locations to be encompassed in less shards and more densely populated areas to be split in to different shards.
When sharding is initiated, it creates shards based off the current user score. These shards need to be persisted in some sort of persistent store or database. This can be used for something like elastic search or location based sharding in any kind of database.
Some trade offs for consideration:
// This can also be serialized and pulled from Redis
// let geoshards = GeoshardBuilder::from(&json_string_from_ddb)).unwrap();
let geoshards = GeoshardBuilder::user_count_scorer(8, Box::new(vec![].into_iter()), 40, 100).build();
let shard_searcher = GeoShardSearcher::from(geoshards);
let shard_user_is_in = shard_searcher.get_shard_user(some_user);
// Query you index based off the shard ^^^