https://slatedb.io logo
Hi all,
# general
a
Hi all, I'm building a stateful stream processing system and plan to use SlateDB for operator state persistence. I want to understand what would be a good design if I want to support operator rescaling, considering the fact that SlateDB is single-writer. Current idea is to have a KeyGroup (a set of keys) as a minimal assignable-passable unit between worker tasks, each KeyGroup will be backed by a single SlateDB instance which can be easily re-created during re-scale/restart for whatever task/worker the KeyGroup is (re)assigned to, so we always have a single reader and a single writer. The question is how feasible it is with respect to SlateDB memory/CPU overhead, considering caches, compaction, etc. - obviously the more KeyGroups I have the better, however each one will have a memory overhead associated with it, so I need to figure what is a reasonable estimate of number of Key Groups (per cpu/worker/operator/pipeline?) and associated SlateDB memory usage: from my research, taking a conservative 32Mb per SlateDB instances (is it a reasonable number?) with 1000 of KeyGroups (per whole pipeline - is it a reasonable number?) will give 32Gb of memory overhead just for SlateDB to work, which is not necessarily will be fully utilized at all? Also what about compaction overhead (is it CPU intensive?)? Does it look reasonable w.r.t design and estimations? What config options should I pay attention to? Whats the minimal viable memory footprint for a SlateDB instance in this scenario?
a
Welcome Anov! We spent a ton of time doing just this before our company pivoted. There was a discussion on slack a little bit ago discussing the memory overhead of a single SlateDB instance: https://discord.com/channels/1232385660460204122/1232385660946616433/1410139372346675281 so I think it's fair to assume it'll be closer to 64MB/instance by default though you could tune down the memtable size (you may want to read that discussion through). Note that this is "unutilized" so to speak as that holds 64MB of real in-memory data so it's not just overhead. When we were building our slatedb-backed state storage for operators we ended up having a fixed number of slateDB instances per stream partition (and we found that 1:1 actually works decently well, so for a 128 partition pipeline we would run 128 slateDB nodes but obviously YMMV depending on your workload). Re: caching/GC. Those were both design to run on nodes that aren't the active writer, so you can have separate processes that run them on a schedule if you want to avoid affecting the main memory task. I'll let @Rohan chime in and see if anything else comes top of mind re: configs we had to tune to make it a reality
r
64MB should be reasonable to account for memtable though in practice it may be more for short intervals if memtable flushes get delayed for some reason. 64MB should give you headroom for the memtable and one immutable memtable waiting to flush. The other big consumer of memory is the cache, but you can create a single cache and share it amongst all your slatedb instances Generally I'd say that it would be better to try to keep the number of slatedbs on a given node bound to some number if you can. There was some work done recently to support splitting and merging slatedbs when making a clone from a checkpoint. That should allow you to slice up a given slatedb and then create a reorganized slatedb when your assignment of key groups changes > Re: caching/GC. Those were both design to run on nodes that aren't the active writer I think you meant compaction here @almog ?
a
> I think you meant compaction here @almog ? ๐Ÿคฆ yes! I mean compaction. thanks!
a
> Generally I'd say that it would be better to try to keep the number of slatedbs on a given node bound to some number if you can. There was some work done recently to support splitting and merging slatedbs when making a clone from a checkpoint. That should allow you to slice up a given slatedb and then create a reorganized slatedb when your assignment of key groups changes @Rohan, can you elaborate on this a bit? I looked for "splitting and merging" functionality but could not find anything - do you refer to creating a writable db clone from checkpoint? If so, this can work and maybe even better than db-per-keygroup wrt memory overhead - when keygroup moves to another node, we simply create a writable clone refering to previous db owning this keygroup, however the problem I see is that with each new rescale 1) the dependency chain will grow deeper refering the original db, even if it's not used anymore (is it something to be actually concerned about, does it impact SlateDB perf?) 2) the number of dbs is still not limited per node, we potentially may have uncontrollable number of dbs if fragmentation becomes bad as number of rescales grows. For 1), we may ease it a bit if we originally have not one db per node but multiple (the dependency depth will be "spread" between them, but still grows) - is it what you refer to when saying "keep the number of slatedbs on a given node bound"? For 2), I'm not sure how to limit the number of dbs for arbitrary number of rescales - is there something in SlateDB API I can use (like merging dbs), or maybe something that handles this internally?
c
@anov digging out of GH notifications. Left a brief note on https://github.com/slatedb/slatedb/issues/943#issuecomment-3429744084
Unfortunately, I don't think split/merge is exposed to users right now.
> 1) the dependency chain will grow deeper refering the original db, even if it's not used anymore (is it something to be actually concerned about, does it impact SlateDB perf Yes, if you have enough cruft lying around, it'll bloat metadata and slow reads. But compaction should help manage this since it'll replace external SSTs with newer SSTs that belong to the new DB (and remove the old SSTs if they're no longer used).
a
It's not only the metadata concern, but the actual db creation logic, as the number of db's on a single machine may grow uncontrollably leading to memory overhead, though it's more of a corner case, but still. So, whats my safest bet here? 1) db-per-keygroup with lots of small db's and lot's overhead, but controllable number of them or 2) single db per worker for multiple keygroups which I will fork/clone during rescale when keygroup distribution changes, though it may lead to unpredictable metadata/memory bloat? In general, storing streaming state looks like one of the top usage scenarios for SlateDB, would be great to have some sort of tutorial/example for this. Btw is there a chance I can count on split/merge to be done any time soon? @criccomini @User @User
c
> Btw is there a chance I can count on split/merge to be done any time soon? Unfortunately, @dmvk isn't around anymore. He was the one working on it. I'm not sure if the Responsive crew (or anyone else) has plans to work on it. I don't plan on doing it in the near future.
> as the number of db's on a single machine may grow uncontrollably leading to memory overhead I'm curious, can you maintain an LRU cache type thing and keep the most recently N DBs per machine open? They're not super expensive to close and re-open.
d
Itโ€™s not far from being complete. Iโ€™m slowly getting motivation to start coding again, but not quite there yet. Iโ€™d hope that Confluent folks would take over from where Iโ€™ve left off, but Iโ€™d need to catch up with them. Whatโ€™s the use case / company looking for this?
c
@dmvk the use case is described here: https://github.com/slatedb/slatedb/issues/943 But the gist is:
>I'm building a stateful stream processing system and plan to use SlateDB for operator state persistence. I want to understand what would be a good design if I want to support operator rescaling, considering the fact that SlateDB is single-writer.
d
So basically matches the flink use case ๐Ÿ‘
c
Yep, totally.
> Iโ€™m slowly getting motivation to start coding again, but not quite there yet โค๏ธ
It's good to see you on Discord again at least ๐Ÿ™‚
Hope you're enjoying your break
d
yeah, so far so good ๐Ÿ™‚ but it's about time to get back to something more real than a sailing licence ๐Ÿ˜„
a
Sailing license is very real! Smallboat? Megayacht? What are you sailing?
(and welcome back to discord @dmvk ๐Ÿ‘‹, I've been enjoying picking up your merge operator stuff to code out)
d
just for a regular sailing yacht; it's limited to ~40ft yachts and 20nm from coast
Europe is way stricter than US in this regard
> I've been enjoying picking up your merge operator stuff to code out Nice, looking forward checking it out ๐Ÿคฉ
a
@criccomini I got a CI test failure for
Copy code
FAIL [   0.026s] slatedb dispatcher::test::test_executor_propagates_handler_error_drains_messages
Might be worth digging into whether it can be flaky
c
Will do. I'm poking at the timeout we got on GH nightly last night.
Messing with the event handling always breaks tests. There are so many assumptions baked into some of them...
Think I figured out the issue..
Forgot to pause the cleanup in the test before sending the message that triggers cleanup... means the cleanup can run before the message is sent, and rx (and the dispatcher) can get dropped
gonna try and repro
Yep. a sleep reproduces it every time. fixing