Remember once MongoDB CPU soared 100% solution

Source: Internet
Author: User
Tags mongodb

The discovery process of the problem is this, some hardware equipment uploaded real-time device information client can not show, so the query log, found that the data time delay is very serious, background logic to this data as outdated data thrown away, so there is no access to real-time data services (this service is a separate deployment).

So start to check the problem, the original data is expired. In view of the fog of Beijing may be on the Beidou (PS: Our main equipment, Beidou position data) has an impact, so first look at the Beidou received data, the conclusion is correct.

Then look at the database log, the database before inserting data serious lag, suspect may be too much data backlog, insert slow.

And our background logic is inserted into the database after the successful access to real-time data services, so access to real-time service data is also lagging behind.

In addition, the real-time data service has a coprocessor that checks the timestamp and kicks off if the data expires.

At this point, the approximate problem is found out, real-time service kicked out the data, the client view real-time information of course not see.

In addition, the problem is that the request response to the data playback is extremely slow, at a 30-second level.


Start troubleshooting the possible cause of this problem ~

The code looks normal, backend development patted the chest, passed the logic is really no problem.

Let's look at the deployment problem.

Top A look, the CPU has used 100%, the whole is mongod this occupy.

Start Google,baidu ...


Until I see this article: http://m.blog.csdn.net/blog/roler_/40107751


Our business is characterized by a large number of data, real-time requirements, a lot of data is based on ID and time stamp to carry out the business.

The real-time data for all users is then indexed for IDs and timestamps.

The main commands used are as follows:

Db. Xxx.getindexes () View index

Db. Xxx.ensureindex ({id:1}) set index


The CPU came down in an instant.


I have to look at it now, but I think the problem has been solved ~


The problem is not terrible, mainly through learning to solve it, I now want to find a reliable Yun-wei, help me do these things, welcome everyone to harass.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.