NodeJS connection and database connection

I experimented with clustering in NodeJS ( https://nodejs.org/api/cluster.html ) and was able to copy my server.

I have a mongodb connection that is established when the server starts

Previously, this was not a problem since it is installed once (without a cluster).

I think with clustering, it installs once for each cluster (I don't understand).

So, should the connection be performed once for the entire server (or) once for each worker (or) only for the master process?

What is the recommended method and how can it be achieved?

Thanks in advance.

+4
source share
1

. . connect-mongo , , - , . , .

0

Source: https://habr.com/ru/post/1665259/


All Articles