A
A
Alexey Yarkov2016-01-26 11:32:03
MongoDB
Alexey Yarkov, 2016-01-26 11:32:03

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:
6f7ff44071614425a3b0dd6efd0596a9.png
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

3 answer(s)
T
Timur Shemsedinov, 2016-01-26
@yarkov

The mongo driver has a default connection pool = 5, this can be changed, see here:
https://mongodb.github.io/node-mongodb-native/driv...

L
lega, 2016-01-26
@lega

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.

L
lagvi, 2020-09-25
@lagvi

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 question

Ask a Question

731 491 924 answers to any question