Answer the question
In order to leave comments, you need to log in
How to reduce mongodb server load?
Hi, damn right now I’m in no mood at all, help brothers.
I have mongodb as database.
In a certain table for example messages there are 10.000 records (documents of the table).
I enabled setInterval 1 sec, and every second I have a request to the database to display 200 messages (the size of each message is 2.5kb) out of 10.000, and this operation takes me 1.5 sec, BUT if I set setInterval 10 ms instead of 1 sec, then the operation time will slowly increase, why did I set 10 ms instead of 1 sec? It's like a load test. Actually the question is: what to do? brothers i know you are with me xD
Answer the question
In order to leave comments, you need to log in
It would be useful to show the query itself, maybe an additional index would solve the problem.
If the speed of adding new records is low, then you can select data from the database, write everything to some global / local variable in the given scope, and take all subsequent readings from the variable, instead of querying the database.
When a new entry is added, make a new query to the database, and again write everything to the global variable.
A sort of caching in memory on the knee.
Or see try caching everything via redis https://github.com/conancat/mongoose-redis-cache
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question