How to make a multi-threaded application with Node.js, access to LevelDB?

This is in the LevelUP documentation ( https://github.com/rvagg/node-levelup#multi-process-access ):

LevelDB is thread safe, but not suitable for access with multiple processes. You should only have a LevelDB database open from one Node.js. process. Node.js clusters consist of several processes, so an instance of LevelUP cannot be shared between them.

Therefore, I could not use a Node cluster ( http://nodejs.org/api/cluster.html )

Is there any other way to make a multi-processor (or multi-threaded) Node.js application to access the LevelDB database?

+4
source share
2 answers

I would say level-party is what you are looking for. Of course, in terms of having multiple leveldb for each child thread, I'm not sure if I know the answer to this question.

+1
source

I think your only viable option would be to select one process to own leveldb access and perform all operations and communicate with this process through the network. Or you could just do what everyone else is doing and use a traditional database server that several client processes can access at the same time.

0
source

Source: https://habr.com/ru/post/1524090/


All Articles