Databases 6 min read

How to Diagnose and Resolve MySQL Process CPU Usage Spiking to 900%

This article explains common scenarios that cause MySQL (and related services) to consume 900% CPU, outlines step‑by‑step diagnosis using tools like top and show processlist, and provides practical remediation such as killing offending threads, adding missing indexes, disabling slow‑log, and leveraging Redis caching to bring CPU usage down to acceptable levels.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
How to Diagnose and Resolve MySQL Process CPU Usage Spiking to 900%

Scenario 1: MySQL Process CPU Spikes to 900%

During heavy database operations, CPU usage can suddenly exceed 200% or even reach 900% when many concurrent low‑performance SQL statements run without proper indexes, especially if slow‑log is enabled.

Scenario 2: PHP Process CPU Spikes to 900%

Although PHP normally does not perform heavy CPU work, under high concurrency it can also cause CPU usage to soar to 900%.

Other Scenarios

Similar CPU spikes can occur with services like Redis or Nginx.

MySQL Process CPU Spiking to 900% – How to Handle?

Diagnosis Steps:

Use top to confirm that mysqld is the culprit.

If it is, run show processlist; to view active sessions and identify resource‑intensive SQL.

Examine the offending SQL, its execution plan, and check for missing indexes or excessive data volume.

Remediation Process:

Kill the problematic threads while monitoring CPU drop, then adjust the queries (add indexes, rewrite SQL, tweak memory parameters) and restart them.

If missing indexes are found, create them; if many sessions flood in, collaborate with the application team to limit connection counts.

Optimization is iterative: apply one change, observe the effect, then continue refining.

In a real incident, a poorly written SQL caused MySQL CPU usage to exceed 900%. After adding the appropriate index and moving frequent reads to Redis cache, CPU stabilized around 70‑80%.

Key observations:

Avoid enabling slow‑log when CPU is already high; it can further degrade performance. show processlist quickly reveals the heavy SQL statements, often pointing to index, lock, or large‑table issues.

Introduce caching (e.g., Redis) to reduce query frequency on MySQL.

Memory tuning can also help alleviate CPU pressure.

Do not turn on slow‑log during high CPU usage because it adds disk I/O overhead.

Use show processlist to pinpoint problematic queries and address index or query inefficiencies.

Employ a cache layer to offload read traffic from MySQL.

Consider memory parameter adjustments as part of the solution.

In summary, the incident was resolved primarily by adding missing indexes and integrating caching, which together reduced CPU consumption dramatically.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

SQLindexingcachingmysqlCPU
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.