tencent cloud

Feedback

Troubleshooting High CPU Utilization

Last updated: 2024-01-15 14:49:55

    Problem Description

    The CPU monitoring metrics stay high on the System Monitoring tab on the Instance Details page of an instance in the TencentDB for MongoDB console.

    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.
    Many unexpected or malicious requests may lead to 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: A large number of physical reads and logical reads may be caused due to insufficiently covered fields or unreasonably ordered index fields, using more CPU resources.
    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 indicates that a full-collection scan is performed for the query.
    docsExamined indicates the number of documents scanned. The larger the docsExamined value, the more the documents scanned, and the more the CPU resources used.
    Unreasonable index keywords:
    IXSCAN indicates that an index scan is performed.
    keysExamined indicates the number of index entries scanned. The larger the keysExamined value, the more the index entries scanned, and the more the CPU resources used.
    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 nodes: If mongos hits the bottleneck, upgrade the mongos node specification or add more mongos nodes as instructed in Adjusting Mongos Node Specification or Adding Mongos Node respectively.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support