Answer the question
In order to leave comments, you need to log in
Why are there so many connections to Mongo?
I'm running the chat script. It connects to Mongo once, but in the terminal I see this:
Where are the 5 connections from?
The connection is at the beginning of the script:
// Подсоединяемся к БД
var db = mongoose.createConnection(config.get('mongoose:uri'));
Answer the question
In order to leave comments, you need to log in
The mongo driver has a default connection pool = 5, this can be changed, see here:
https://mongodb.github.io/node-mongodb-native/driv...
Because the script is asynchronous and requests are received in parallel, so in order to process requests in parallel, you need several connections in parallel.
We installed 150 connections on our project, because some requests were processed for a long time and users experienced brakes. Requests were queued. After increasing the number of connections, the speed increased significantly, because. the queue of pending requests has become almost empty. So this is a useful feature.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question