P
P
PAJCH2015-12-08 18:56:00
JavaScript
PAJCH, 2015-12-08 18:56:00

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

4 answer(s)
E
Evgeny Yablochkin, 2015-12-08
@PAJCH

It would be useful to show the query itself, maybe an additional index would solve the problem.

A
Alexander Melekhovets, 2015-12-08
@Blast

Strip-Probl%C3%A8me-dIndex-650-finalengl

D
Dmitry Gusev, 2015-12-08
@illi

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

A
Alex10, 2015-12-09
@Alex10

As an option to disable authorization if enabled, it will help.
In general, it's good to give the version of mongodb and the hardware parameters. Mongo likes more RAM.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question