MyTop, Top for MySQL

ECPod must have jumped a bit in popularity, as today, while skim-reading the error log I noticed a lot of these:

[exception 'PDOException' with message 'SQLSTATE[00000] [1040] Too many connections' in ../includes/classes/db/connection.php5

My initial reaction was to simply increase the connection limit in /etc/my.cnf. After doing that I also went through parts of our codebase that create new DB connections, and refactored them so that they now reuse an existing connection if possible – should have been that way from the start, but things like that can be missed when under a hectic development schedule.

Damage control over, I ran `top` to check the load of our database master. This made me wonder if there is a similar tool available that allows monitoring of a mysql instance.

There is, it’s called mytop. It’s even in the CentOS repository!

A quick yum install later, and I am now able to monitor mysql’s performance in real-time, just like I can for the whole server with top.

Here’s a screenshot of it in action:

MyTop Screenshot

Great to be able to see queries per second, average queries per second, total queries, mysql uptime etc all in one place, and it’s quite interesting to watch if for a few minutes to see the queries as they’re being made. Also shows key buffer efficiency (how often keys are read from the buffer rather than disk).

In all, very helpful!

No comments | Trackback