tencent cloud

TencentDB for MongoDB

High CPU Usage Solution

Download
Focus Mode
Font Size
Last updated: 2026-10-23 20:44:38
AI-Translated

Problem Description

For daily Ops, log in to the MongoDB console, click an instance ID to go to the Instance Details page, select the System Monitoring tab, and check the instance monitoring metrics. If the database CPU monitoring metrics are significantly and continuously high, perform further analysis. 

Troubleshooting

No.
Possible Cause
Cause Analysis
Troubleshooting Method
Solution
1
Non-persistent connections are established frequently.

A large number of instance resources are used to process frequent non-persistent connections, resulting in a high CPU utilization and many connections. However, the QPS (cluster access requests per second) doesn't meet expectations.
Use DBbrain's performance optimization feature to intelligently analyze the real-time session statistics and data of the database instance and check whether there is a sudden increase in the number of connections. For detailed directions, see Real-Time Session.
Change non-persistent connections to persistent connections. For more information on parameters for different programming languages, see Start Developing with MongoDB.
2
There are many unexpected time-consuming requests on the business side.
A large number of unexpected requests or malicious requests may cause excessive waste of CPU resources.
Use DBbrain's performance optimization feature to check whether the requests from all connected clients to the business are actually needed by the business on the Real-Time Session page.
Use DBbrain's performance optimization feature to directly kill unexpected requests on the Real-time Session page. For detailed directions, see Real-Time Session.
On the Performance Optimization page in the DBbrain console, select the SQL Throttling tab, and create SQL throttling tasks to control the database requests and SQL concurrency by setting the SQL Type, Max Concurrency, Throttling Duration, and SQL Keyword. For detailed directions and use cases, see SQL Throttling.
3
There are highly complex requests.

Highly complex requests may cause excessive usage of CPU resources for the following reasons.
Sorting operation: Sorting during the query itself will consume a lot of CPU resources.
Full-collection scan: If the database does not have an index, the request may perform a full-collection scan, putting a high pressure on CPU and IO resources and resulting in performance drop.
Unreasonable index: It may cause a large number of physical and logical reads and consume a lot of CPU resources due to insufficient covered fields and unreasonable order of index fields.
Highly complex query requests are usually time-consuming and generate slow logs accordingly. You can use DBbrain's performance optimization feature to perform slow log analysis and check whether there are relevant keywords in the slow log list. For detailed directions, see Slow SQL Analysis.
Sorting keywords: Sort, hasSortStage, etc.
Full-collection scan keywords:
COLLSCAN
docsExamined
Unreasonable index keywords:
IXSCAN
keysExamined
For slow queries, perform index optimization.
Use DBbrain's index recommendation feature to select the optimal index.
Improve the database performance as instructed in Optimizing Indexes to Break Through Read/Write Performance Bottlenecks.
4
5
6
There are insufficient resources as the business grows.
The CPU specification of the current instance is insufficient as the business grows and the data volume increases.
Log in to the TencentDB for MongoDB console and click the ID of the target instance to enter the Instance Details page. Then, select the System Monitoring tab and check whether the Total Requests (QPS) metric of the instance is obviously higher.

Adjust the instance specifications.
Mongod node: Upgrade the CPU and memory configuration of mongod as instructed in Adjusting Mongod Node Specification.
Mongos node: If Mongos reaches a bottleneck, upgrade the Mongos node specification or add more Mongos nodes. For detailed operations, see Adjusting Mongos Node Specification and Adding Mongos Nodes.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback