Remember once MongoDB CPU soared to 99% problem solved

Source: Internet
Author: User
Tags cpu usage

Business adjustment, a part of the data from Redis to MongoDB, the business in the test environment, the production environment on the line after the discovery of the pressure MongoDB services directly to the CPU full, and the development of the classmate analysis of a bit also refer to Baidu on similar issues, Last location reason: Index not used.

The workaround is simple: Create an index of the corresponding key field.

The reference commands are as follows:

>use Data; #进入数据库Data, pay attention to case sensitivity;

>db.stats (); #查看数据库的状态;

>db.getcollectionnames (); #查看所有表名;

>db.dynamic.find (). Limit (5); #查看dynamic表的前5条数据;

>db.dynamic.find (). Count (); #统计dynamic表总共有多少数据;

>db.dynamic.getIndexes (); #查询表dynamic的索引


#新建索引: Score fields for dynamic are indexed in backgroud manner

> db.dynamic.ensureIndex ({score:1}, {backgroud:true});


#状态查看: 20 seconds, updated once per second

mongostat -h 80.81.2.3 -p 27017 --rowcount 20 1


The field that started creating the index is not accurate, the effect is not obvious, and then the CPU usage is dropped after the index of the key field is created.

This article is from the "drag tail in the painting" blog, please be sure to keep this source http://cangzihu.blog.51cto.com/6671848/1904765

Remember once MongoDB CPU soared to 99% problem solved

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.