Sunday 14 May 2017

PM2 clustering, WebSockets, Nodejs(express) how to implement shared data(variable)

I am writing real time connection web server with WebSocket(ws) library in Node js(Express) where i an saving users in a variable clients to be able to find the right ws user to send data. The clients variable is array of objects. At the end i am going to connect PM2 clustering and i need to share all the clients between all worker and master processes, i was thinking to use mongodb to save data but i am doing alot of data modification which may lead to slow down the server very often data update.

Is there any way to make share data between pm2 clusters faster to work with and more consistent. I need very often access Clients variable and update it very fast to have persistent data between all clusters.

Thank you very much.



via Dmitrii Goriunov

No comments:

Post a Comment