Why mongodb load the system to 100%?

Good morning colleagues, I have this problem:
You have a server:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
CPU MHz: 3699.984
BogoMIPS: 7200.07
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
64 gb of memory and 520gb ssd

Active connections: 14917
server accepts handled requests
277170 277170 36352500
Reading: 0 Writing: 6100 Waiting: 8770

On the server ustanovlen nginx+php5-fpm and mongodb at the moment the server is overloaded with 15K users, 7 of which nginx manages obrabotat, the others weigh in the status of Waiting: 8353
htop shows that all CPU cores are loaded and the hardest process is mongodb, tell me where to dig and what to do!
July 12th 19 at 17:29
4 answers
July 12th 19 at 17:31
Optimize your database queries.
I myself have had the same problem(though in mysql, but the point I think is the same). The problem was that I was doing a lot of queries on 1 table(select and update) with 1.5 M entries=>requests were made for 1+ second=>we are going to turn=>loaded processor. Solved the problem by removing the request read from this table by making a separate table, where there were already counted values.

Upd. Not familiar with mongodb, but googled analogue SHOW PROCESS LIST for mongodb: https://docs.mongodb.org/manual/reference/method/d...
if only I could do it :)
Yes, and mongo is, but I with it did not work! - jessyca_Daugherty commented on July 12th 19 at 17:34
: view the list of processes running - Iva.Blanda60 commented on July 12th 19 at 17:37
July 12th 19 at 17:33
prompt where to dig and what to do!

For starters keep track of, that's his ship. If the culprit is found - to forgive and understand.

If not found: split the system across multiple servers.

15K users

This is rps, or a constant number of open connections?
it's a constant number of users found the culprit, it's mongodb, but what's wrong with her I can't understand! - jessyca_Daugherty commented on July 12th 19 at 17:36

Monga itself does not load. Load create queries its load. You need to define what it uchityvaet.

> is a constant number of users
the load is not measured in users)) Load is measured in Request Per Second (rps), the number of competitive podolyany (tcp open connection), *bits/sec - Iva.Blanda60 commented on July 12th 19 at 17:39
July 12th 19 at 17:35
https://docs.mongodb.org/manual/tutorial/manage-th...
Include log slow queries and see what the problem is.
Certainly the index somewhere forgot to add the monga and any queries brute force pulls out.
MongoDB shell version: 2.4.14
connecting to:
> db.getProfilingLevel()
1
> db.getProfilingStatus()
{ "was" : 1, "slowms" : 20 }
>

log is enabled but in the log I don't see slow requests... - jessyca_Daugherty commented on July 12th 19 at 17:38
July 12th 19 at 17:37
Probably need indexes are not added.
Programari watched, everything is OK, the side purely on the server side but I can't figure out where at the moment already Active connections: 22629
server accepts handled requests
613790 613790 58310648
Reading: 4 Writing: 13237 Waiting: 9320 - jessyca_Daugherty commented on July 12th 19 at 17:40
:
> Programari watched, everything is OK
They probably just dump you on unnecessary work.

Turn on profiling, to catch a few tromagnetic queries and lay out here.
Then we can say what the trouble, basically there are 2 possible reasons:
1) Curve request (without index)
2) can Not cope iron - Iva.Blanda60 commented on July 12th 19 at 17:43
Mongostat show more - jessyca_Daugherty commented on July 12th 19 at 17:46
: you were right, they were trying to get off the topic, it turned out that Java script is not shielded by quotation marks and not true worked the script, now everything is normal, but wanted to sprot that in the future this was not how to get nginx to show what links are and what scripts zataplivaet? something like apache2 server_status? - Jayme91 commented on July 12th 19 at 17:49
> nginx show what links are and what scripts zataplivaet
no such, they are not, it all depends on the code on the server.

We can measure query execution time, while getting / sending, how long the query worked and if it is slow then put it in logs or somewhere else. And then to deal with them. - jessyca_Daugherty commented on July 12th 19 at 17:52
in nginx there is a normal access_log, it is possible to add time script - and then or self-made script or service datadoghq.com - jessyca_Daugherty commented on July 12th 19 at 17:55

Find more questions by tags PHPNginxMongoDB