What Should I Do When the CPU Usage of My RDS MySQL DB Instance Is High?
If the CPU usage is high or close to 100% when you use RDS for MySQL, data read/write processing is slow, connections cannot be obtained, and errors are reported, affecting your service running.
- View the slow SQL logs to check whether any slowly executed SQL queries exist and view their performance characteristics (if any) to locate the cause.
For details on viewing MySQL logs, see section Viewing and Downloading Slow Query Logs.
- View the CPU usage metric of your RDS DB instance to facilitate problem locating.
For details, see Configuring Displayed Metrics.
- Create read replicas to offload read pressure on primary DB instances.
- When multiple associated tables are queried, indexes must be created for the associated fields.
- Do not use the SELECT statement to scan all tables. You can specify fields or add the where condition.
- You can use the Data Admin Service (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 database according to the diagnosis suggestions to ensure the stability of the database performance.
For details, see SQL Tuning.