Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

High CPU Usage of RDS for MySQL Instances

Updated on 2025-01-02 GMT+08:00

If the CPU usage of your RDS for MySQL instance is high or close to 100%, database performance deteriorates. For example, data read/write becomes slow, connecting to the instance takes a longer time, or errors are reported when you are trying to delete data.

NOTICE:

The following functions of Data Admin Service (DAS) are only available to the accounts that are using them, from November 25, 2021, 00:00 GMT+08:00: SQL tuning, table structure comparison and synchronization, data tracking and rollback, data generator, and DBA intelligent O&M in Development Tool, as well as space, intelligent parameter recommendation, historical transaction, and binlog parsing functions in Intelligent O&M.

  • For DB instances created after November 25, 2021, 00:00 GMT+08:00, Solution 1 is recommended.
  • For DB instances created before November 25, 2021, 00:00 GMT+08:00, Solution 2 is recommended.

You are advised to enable SQL audit in advance so that you can view SQL execution records in audit logs to locate the fault when the CPU usage is high.

Solution 1

Analyze slow SQL logs and CPU usage to locate slow queries and then optimize them.

  1. View the slow SQL logs to check for slowly executed SQL queries and view their performance characteristics (if any) to locate the cause.

    For details on viewing RDS for MySQL logs, see Slow Query Log.

  2. View the CPU usage metric of your DB instance.

    For details, see Performance.

  3. Create read replicas to reduce read pressure from primary DB instances.
  4. Add indexes for associated fields in multi-table association queries.
  5. Do not use the SELECT statement to scan all tables. You can specify fields or add the WHERE condition.

Solution 2

You can identify slow query statements and optimize them according to the suggestions provided by DAS to reduce the CPU usage.

  1. Connect to the RDS for MySQL DB instance.

    You can connect to an instance through a private or public network. For details, see the Relational Database Service Getting Started.

  2. Run the following command to show the running threads and locate the queries that are slowly executed:

    show full processlist

    Check the values in the Time and State columns. As shown in the preceding figure, the long-running transaction ID is 4038566.

  3. Use SQL diagnosis of DAS to identify SQL statements that are executed frequently, consume a large amount of resources, or take a long time to execute. You can optimize the statements according to the diagnosis suggestions to ensure the stability of the database performance.

    1. Log in to the DAS console.
    2. In the navigation pane, choose Intelligent O&M > Instance List.
    3. Click Details on the instance.
      Figure 1 Instance list
    4. Choose SQL > SQL Diagnosis.
    5. Select a database, enter an SQL statement, and click Diagnose.
      Figure 2 SQL diagnosis
    6. View diagnosis details and obtain statement optimization suggestions.
      Figure 3 Tuning details
      NOTE:
      • Only the diagnosis of SELECT, INSERT, UPDATE, and DELETE statements is supported. An INSERT statement must contain a SELECT clause.
      • SQL statements for querying system databases like information_schema, test, and mysql are not supported.
      • SQL statements that use views are not supported.
      • Using SQL diagnosis can obtain table structure and data distribution information (non-original). The obtained information is only used for logic diagnosis, but not stored on the DAS server.
      • Obtaining table structure and data distribution information may cause additional load on the DB instance, but has little impact on its performance.
      • Only the SQL diagnosis history is stored on the DAS server. You can delete it from the server permanently.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback