Loading a DB document takes more than 2 mins
I have a KOA (instead) app to load the some ENV variables from DB and use them in App, everything was working fine but suddenly loading a single document takes more than 2 mins which is damn frustrating. The db has only one document.
I tried to load data from other app and it loads data fine.
I have a static method, to create conn and load config,
public static createConn() { mongoose.connect(MongoEnv.MONGO_URL, { user: MongoEnv.MONGO_USER, pass: MongoEnv.MONGO_PASSWORD, useNewUrlParser: true, useCreateIndex: true, autoReconnect: true, connectTimeoutMS: 180000, socketTimeoutMS: 180000 }); }
public static async loadEnvVariables() {
const start = Date.now();
this.config = await Config.findById({ _id: 'nestor-ui-config' });
const millis = Date.now() - start;
console.log(load mongo config took ${millis} mseces);
console.log(this.config);
}
and I call these two methods from serve.ts. here are the package versions I use, "mongoose": "^5.5.8", "koa": "^2.7.0"
I am not sure if this is an issue with mongoose, if any help will be mush appreciated. Thanks.
Are you executing other queries at the same time? Sounds like a slow train problem.