The efficiency of mongodb concurrent query is very low.

personal blog A personal blog written by has a concurrency problem: using Aliyun"s pts to test concurrency, it is found that when the number of concurrency reaches 8 (which is negligible), the database query is particularly slow (there is very little data in the database)? I would like to ask from which aspect should I think about and solve this problem, and how to optimize it? At present, it can be determined that the problem is caused by the database.
the connection code is as follows:

mongoose.connect("mongodb://***.***.***.***:27017/blog",{useMongoClient:true,
    user:"**************",
    pass:"********************"
},()=>{
   http.createServer((req,res)=>{
       res.writeHead(302, {"Location": "https://www.hejuncai.com" + req.url});
    res.end();
   }).listen(80);
   https.createServer(options,app).listen(443);
});

the query code is as follows

Content.find({//
        lassification:getArticleID ||  {"$ne":null, $exists: true }
      },(err,doc1)=>{                                      
                if(err){
                    console.error(err);
                    return false;
                }
                res.render("main/index",{      
                    content:doc1 || "",//
                });
            }).sort({_id:-1}).limit(10);




Mar.18,2021

it is recommended to change the development language

Menu