NodeJS cluster and database connection
|Added at||2016-12-29 21:12|
I have been experimenting clustering in NodeJS (https://nodejs.org/api/cluster.html) and was able to cluster my server.
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.