Как мне управлять подключениями MongoDB в веб-приложении Node.js?

Я используюУзел-MongoDB-родной драйвер с MongoDB, чтобы написать сайт.

У меня есть несколько вопросов о том, как управлять соединениями:

Is it enough using only one MongoDB connection for all requests? Are there any performance issues? If not, can I setup a global connection to use in the whole application?

If not, is it good if I open a new connection when request arrives, and close it when handled the request? Is it expensive to open and close a connection?

Should I use a global connection pool? I hear the driver has a native connection pool. Is it a good choice?

If I use a connection pool, how many connections should be used?

Are there other things I should notice?

Ответы на вопрос(10)

Ваш ответ на вопрос