https://slatedb.io logo
weird question: is there a way to share
# general
a
weird question: is there a way to share the periodic object store WAL flush API call among many instances of slatedb? context: i want to split up my keyspace into many different slatedb instances for vnode-style sharding. i want autoscaled compute / storage separatation, which means i'll have a pool of compute nodes that is changing all the time, and a mapping of which shard of my keyspace is owned by which node at what time that all the nodes agree on. when a new node comes into the ring, it will take ownership of some of the shards, and the old owner will close those slate db instances and the new owner will open them and there will be much rejoicing. the problem is that i have to pick a high shard count to guarantee future scalability. if i pick a low shard count like 4, then i can have max 4 compute nodes total, because the shards are indivisible. so, i'd love to pick a high shard count like 200, and start with 4 compute nodes each running 100 of the shards, but allowing more and more compute nodes to be added over time to spread the instances out wider and wider. this is how temporal works internally with their history shards mapping to history nodes too. the problem with this approach is that if i open 200 slate db instances across all my compute nodes, and set a 100ms flush interval, im now flushing every 100ms * 200 instances, really driving up object storage operation counts and costs. squinting a little, i dont actually need one flush per instance every 100ms, i only need one flush per process per 100ms. are there any facilities for batching the flushes together, while keeping the instances separate such that they can be closed and reopened elsewhere? or other approaches that would allow this nice compute/storage separation that minimize flush volume?
r
There currently isn't a way to share the WAL across multiple DBs. I think the right way to do what you want what be to support the ability split/merge dbs. That way you could start with a slatedb per node, and then when a new node comes online have it create a clone of the db with the data it needs and split it so that it only references the data from its shard. We're close to being able to support this. You can create checkpoints and clone them, and our internal data structures support projecting subsets of the key range (fundamental for splitting). But it hasn't been exposed via the api yet.
Unfortunately there isn't currently an ETA on when we'd support split/merge. It isn't being actively worked on. You're more than welcome to pick it up 🙂
a
that makes sense and would indeed work! just from a complexity perspective, i must say it would be simpler for me as a user of the lib to not have to actually split or merge database instances and worry about the data actually moving around. i totally get how that primitive enables what i want, but its more invasive than i would hope, in that i have to be careful to split and merge properly and track what has been properly split or merged somewhere outside the instances themselves. what do you make of an approach where the WAL writes and WAL flush-er could be shared by many instances at the same time? some multiplexer doodad that could coalesce flushes from many instances into one flush, and then on replay, ignore data from all but the one instance that cares
r
I've thought about that a bit before to solve a similar use case for myself. I think it's doable, though GC gets pretty tricky. That said there's a few other downstream problems with this kind of setup that you'd have to solve next. In particular this approach will force you to either allocate a ton of memory to accommodate all the memtables (this will also drive up recovery times since the segment of the wal required to recover any given db gets bigger), or force you to write really small memtables which ratchets up compaction pressure.