Select Page

Bobcares Blog

Tried and tested solutions for your servers, from our outsourced support diaries.

How to fix MySQL high CPU usage

How to fix MySQL high CPU usage

Almost all open source web applications use MySQL as its database. It’s easy to use and is supported by all hosting providers. However, many websites often face performance issues due to MySQL high CPU usage.

MySQL databases grow in size, and tables get fragmented over time. This contributes to MySQL load spikes. So, protecting a website from MySQL high CPU issues requires close monitoring and periodic optimization.

At Bobcares Preventive Server Maintenance Services, there are 3 key operations involved in keeping MySQL stable:

24/7 monitoring

A vulnerability in MySQL settings is usually revealed when there’s a spike in server traffic. So, it is important to keep a close watch on MySQL metrics round the clock. Our experts monitor MySQL health 24/7, and react when there’s an issue.

Emergency rescue

When we detect an anomaly, like slow MySQL response times, we immediately login to the server, kill the abusive connection, and restore normal operating speeds.

Follow-up audit & optimization

However, rescuing MySQL is just the first step. We then audit MySQL settings to see WHY a response issue happened in the first place, and then optimize the tables and tweak MySQL settings so that it won’t happen again.

 

[ Making your MySQL crash proof doesn’t have to be hard, or costly. Our Server Maintenance plans start at $25/month. ]

Today, we’ll take a look at how we react to a MySQL high CPU situation, and what we do to prevent its recurrence.

How to detect MySQL high CPU usage

Very often people link high server load to high CPU usage. That is not always true. Server load can go high due to bottlenecks in any resource. This can include memory, disk I/O, network or CPU.

The top reason for MySQL induced server load is due to memory or I/O exhaustion. If it is CPU bottleneck, the output of top would look like this:

top - 8:31:15 up 23 days, 3:33, 1 user, load average: 22.31, 19.72, 25.02
 Tasks: 81 total, 5 running, 76 sleeping, 0 stopped, 0 zombie
 Cpu(s): 87.8%us, 0.3%sy, 0.0%ni, 11.2%id, 0.0%wa, 0.2%hi, 0.5%si, 0.0%st
 Mem: 2975920k total, 1018219k used, 1957701k free, 287408k buffers

If it is I/O induced bottleneck, the %wa (called wait average) will have the highest CPU%. In contrast, if it is a memory induced load, the “free” memory would be limited to just a few MBs.
Click here to know how to fix a MySQL high memory usage situation.

PROTECT YOUR SERVER TODAY!

Never again lose customers to poor page speed! Let us help you.

We keep your servers optimized, secured and updated at all times. Our engineers monitor your applications 24/7 and fix issues before it can affect your customers.

Sign Up once. Enjoy Peace Of Mind For Ever!

SIGN UP FOR AS LOW AS $25/MO

Bobcares provides Outsourced Web Hosting Support and Outsourced Server Management for online businesses. Our services include 24/7 server support, help desk support, live chat support and phone support.

1 Comment

  1. Thank you *very much* for your advice. Came home today, the first day of January 2017, to find my mariadb process taking up about 40% CPU … with no database queries, should have been totally idle. As my server (Centos 7) is running on an Amazon ‘T2’ instance which relies on never running out of ‘CPU credit’ – which for my machine means only using an average of 20% CPU – this was a concern. Another half day of this and I would have been sunk.

    I read your article, not thinking I was going to find anything to help … saw your item #5 … ran the ‘date’ command … and CPU has dropped to zero.

    THANK YOU!

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *





About Bobcares

Bobcares Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services.
Our engineers manage close to 52,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.
MORE ABOUT BOBCARES