node.js - Connecting to many databases at once in mongo/mongoose -


we trying connect 1500 databases using mongoose it's slow create 1500 connection 1500 db using command

mongoose.createconnection(url); 

the 1500 db on same database server. took more 50 minutes establish these connections.

is there way decrease amount of time or there way connect 1500 db @ once on same server?

you try async:

'use strict'; const mongoose = require('mongoose'),     async = require('async'),     dbsurl = [     'mongodb://url1',     //...     'mongodb://url15000', ];  async.map(dbsurl, (url, callback) => {     let conn = mongoose.createconnection();     conn.once('error', (err) => {         callback(err);     });     conn.once('connected', () => {         callback(null, conn);     }); }, (err, dbs) => {     //if error happenned, callback     //else, dbs array of connections }); 

i not know performance such number of connection though.


Comments