3 ms·
I’m really no expert on sharding but if you’re using increasing ints why can’t you just shard on (id % n) or something?
by bigmadshoe 10mo ago
I’m really no expert on sharding but if you’re using increasing ints why can’t you just shard on (id % n) or something?
- 0x457 10mo agoBecause then you run into an issue when you 'n' changes. Plus, where are you increasing it on? This will require a single fault-tolerant ticker (some do that btw). Once you encode shard number into ID, you got: - instantly* know which shard to query - each shard has its own ticker * programatically, maybe visually as well depending on implementation I had IDs that encode: entity type (IIRC 4 bit?), timestamp, shard, sequence per shard. We even had a admin page wher you can paste ID and it will decode it. id % n is fine for cache because you can just throw whole thing away and repopulate or when 'n' never changes, but it usually does.
- tmountain 10mo ago^ This