I have a mongodb connection which gets established when server starts
Earlier this was not a problem since it gets established once (without cluster).
I think, with clustering it establishes once for every cluster (I am unclear about this).
So, should the connection be done once for the entire server (or) once for every worker (or) only for master process?
Which is the recommended way and how can it be achieved?
Thanks in advance.
NodeJS cluster and database connection
nr: #1 dodano: 2016-12-29 22:12
Connection should be done once for every process. The important thing is however not to mix sessions. I would recommend connect-mongo for sessions and once client establishes session on one of the workers, it should not use any other instance for operations related to this client. This way you can also keep cache for clients on their respectable server instances.