BadgerDB without touching disk?


#1

Is it possible to configure BadgerDB to run without touching disk at all?

I can try to hack it out by tweaking LSMOnlyOptions + MaxTableSize, but I wonder (hope) if there’s a more-official method.


#2

Not a great sign :wink:


(Daniel Mai) #3

You could keep your db directory in a tmpfs mount, in which any disk accesses that happen via Badger would happen in-memory within the tmpfs mount.

Any chance you could elaborate on your use case for a fully in-memory BadgerDB?


#4

You could keep your db directory in a tmpfs mount, in which any disk accesses that happen via Badger would happen in-memory within the tmpfs mount.

Yeah, there are games I can play at the OS/FS layer, and this is probably the best of them, but I’d like to avoid doing anything out-of-process, if possible.

Any chance you could elaborate on your use case for a fully in-memory BadgerDB?

I have a process which is in many respects like a LRU cache. It has state and needs (fast) transactional access to that state, which Badger could provide, but in only one rare configuration does it need to persist that state to disk. It would be ideal to have a single implementation of my storage layer, and flip a switch at runtime to use disk or not.

I spoke with Francesc about this briefly yesterday for a feasibility assessment, and would be happy to go into more detail about my use case with anyone on the core team, if it’s interesting.


(Daniel Mai) #5

We can add an option for a memory-only Badger. There’s already an option to have the tables in memory, and I think there’s already work started to make the value log optional.

Can you file a GitHub issue for this feature request?


#6

Cool! Filed https://github.com/dgraph-io/badger/issues/1001.