in Server

Debugging high CPU on Ubuntu server

Typically my job doesn’t end with a website… more often than not, our clients at We Create Digital are keen to automate, simplify and integrate their business processes within their website. Why? Because it makes their lives easier! Occasionally handling systems which run large database queries on popular websites can be problematic.

I was challenged with a problem on a server which was having high CPU issues. After a few hours of troubleshooting, I was keen to understand what was going on behind the scenes.

I took the following action:

  1. I installed htop using sudo apt-get install htop and after installation I ran htop and could instantly see a mysql process was running at around 180%
  2. Knowing that the database was responsible for the high CPU, logged into mysql and ran SHOW FULL PROCESSLIST and I could very quickly see the query responsible

Fortunately the query was not business critical and could be turned off. The CPU usuage dropped considerably straight away and a new solution is being put together.

Monitoring the server more closely going forward:

We share a Slack workgroup with the client and use a Digital Ocean server to run our application. The solution was obvious… use monitoring Slack alerts and now we can be informed before problems arrise, even when the most carefully planned queries are put together!

Write a Comment

Comment