Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node-persist in cluster mode #93

Open
microSoftware opened this issue Aug 14, 2017 · 4 comments
Open

node-persist in cluster mode #93

microSoftware opened this issue Aug 14, 2017 · 4 comments

Comments

@microSoftware
Copy link

Hi, I run nodejs on ubuntu with pm2 (in cluster mode);
When I persist data (probably on one cluster). I can't access it (probably trying to access it from the other cluster)
I know node-persist don't write the data instantly in disk. But I wait 10s, 30s, 1mn+ and i can't read the data. But if I reload both cluster, every data are accessible.

So my guess is that when node start, node-persist write in RAM all the files in .node-persist/storage/ which explain why it works when I restart.

Is this the intended behaviour when running node-persist in cluster mode ? if so, is there option/work around for this ?

thank you for your help :)

@mgttt
Copy link

mgttt commented Aug 16, 2017

Pattern of node-persist is RAM+FileIO, which not designed for the "concurrent" requirement. So, an standalone writter service for appilcations which in PM2 mode is highly recommended.

P.S. similar solution is also work for node-sqlite3 ....

@microSoftware
Copy link
Author

thanks for your answer. What do you means by "standalone writter" ?

@mgttt
Copy link

mgttt commented Aug 18, 2017

@microSoftware For mine scenario (Some small tools that run in PM2 that have many read actions which I don't want to introduce redis or mysql or mongodb etc), I found no better solution to solve the concurrent conflicts than make a small js-program that listen to a socket to wait for the write command, exec it and return the result. that turns it into a socket-writer-micro-service.... It amazingly works for me... hope my answer satify you, let me know if not ;)

@microSoftware
Copy link
Author

@wanjochan Thank you for the complete answer. It's crystal clear now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants