Skip to content

How to setup LMDB.js in a 'database per user' scenario? #260

Answered by kriszyp
Momics asked this question in Q&A
Discussion options

You must be logged in to vote

I think it sounds like you have a good understanding of the trade-offs here. Maintaining separate databases for each user does incur more memory. As you noted, you can probably mitigate this by lazily opening these databases and closing them when they haven't been used recently (could be an LRU pool, like you mentioned). Also, if writes are scattered across many databases, this can improve concurrency, allowing multiple write transactions in parallel (the write transaction itself has exclusive lock within a database).

Alternately you can setup sub-databases, and this would generally be more memory efficient. If there are many writes that are occurring, this can provide the opportunity for…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Momics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants