node.js - Is it possible to restart NodeJS + socket.io with 0 downtime? -
i running game server using pm2 managing app, messed around cluster mode:
pm2 start app.js -i max pm2 reload and suppose downtime around 0, sockets got disconnected nevertheless. can't use
{reconnection: true} for clients there important things saved on dead sockets , on server itself, data lost crash browser.
everytime need update server js files clients connection lost , that's bad.
taking server down (or restarting) cause data loss items in memory. nodejs might fast in restarting, scripts , objects states lost.
a strategy two-fold: 1) store client information in database, maybe cache db redis or can persist when server restarts. each client have session token identifies them , data wish keep client. 2) store session identifier on connection when client connects server. when client (automatically) reconnects, must go through sequence a) re-establish session b) re-join socket.io room c) restore state (or missed updates).
Comments
Post a Comment