I experience an unusually high cpu usage for the mysql process over Centos usually reaching more than 300% just after restart when not so many users might have connected. I even stopped Apache and my scripts to check if they were the culprits, but the cpu footprint remained the same. The memory usage is instead quite low. I use a very basic my.cnf but tried even with the one at:
http://www.narga.net/optimizing-apachephpmysql-low-memory-server/ with no change.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
max_connections = 200
and this is a a typical top report:
13299 mysql 20 0 142m 19m 5788 S 281.2 0.9 14:14.44 mysqld
13831 root 20 0 10932 3648 2796 S 1.3 0.2 0:00.12 sshd
11103 fabrizio 20 0 2564 956 812 R 0.3 0.0 0:00.58 top
1 root 20 0 2896 360 260 S 0.0 0.0 0:00.15 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/4893
3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper/4893
140 root 16 -4 2460 12 8 S 0.0 0.0 0:00.00 udevd
656 root 20 0 36988 724 320 S 0.0 0.0 0:00.99 rsyslogd
687 root 20 0 9004 332 236 S 0.0 0.0 0:00.50 sshd
695 root 20 0 3272 12 8 S 0.0 0.0 0:00.00 xinetd
890 root 20 0 9204 12 8 S 0.0 0.0 0:00.00 saslauthd
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13299 mysql 20 0 142m 19m 5788 S 298.8 0.9 15:16.08 mysqld
13870 root 20 0 10348 3020 2448 S 2.0 0.1 0:00.06 sshd
1 root 20 0 2896 360 260 S 0.0 0.0 0:00.15 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/4893
3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper/4893
140 root 16 -4 2460 12 8 S 0.0 0.0 0:00.00 udevd
656 root 20 0 36988 732 320 S 0.0 0.0 0:00.99 rsyslogd
687 root 20 0 9004 332 236 S 0.0 0.0 0:00.50 sshd
How may I improve my situation?