mysql is not using multiple cpus

Our MySQL server has been using a lot of CPU lately (it's reached 100% several times and stays there for a while) and I noticed that it the CPU load is all on one core of one cpu. I was hoping to spread that out to all 4 on my server.

I have been tweaking the MySQL settings to use more ram and less cpu, but it still occasionally reaches very high CPU usage.

It seems like everything about the topic refers to thread_concurrency (which I've read is a solaris only setting). What can I do in Linux?

Thanks.


Solution 1:

You are right, thread_concurrency is only for Solaris and it is deprecated in MySQL 5.6 onward. I don't think you can use multi cores/cpus with MyISAM. To fully utilize the hardware, use InnoDB.

This might help you to understand things better.

Solution 2:

The correct value for this variable is dependent on environment and workload. You will need to try a range of different values to determine what value works for your applications. A recommended value is 2 times the number of CPUs plus the number of disks.

The range of this variable is 0 to 1000. A value of 20 or higher is interpreted as infinite concurrency before MySQL 5.0.19. From 5.0.19 on, you can disable thread concurrency checking by setting the value to 0. Disabling thread concurrency checking enables InnoDB to create as many threads as it needs.

http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html#sysvar_innodb_thread_concurrency