artyomboyko
artyomboyko

Reputation: 2871

CPU affinity for mysql server

I have linux server with 4 CPUs. I have mysql installed and i have CPU-heavy tasks that run 24/7 in background. I there any advantages to use CPU affinity for every processes ? For example:

1 CPU = background task/daemon
2 CPU = background task/daemon
3 CPU = background task/daemon
4 CPU = mysql

Each background task eating up to 80% of CPU at any given time.

UPDATE: My tasks are lxml parsers (python).

Upvotes: 0

Views: 1571

Answers (1)

kurtzbot
kurtzbot

Reputation: 512

I would take a look at what your processes are doing. If the scheduler keeps switching the tasks around onto different cores/CPUs, then you could see a performace gain by locking them to a particular core/CPU. The benefit comes from not having to do an expensive context switch between the two cores/CPUs each time.

If you aren't seeing this happening, then I don't see the need to lock them to particular cores when the scheduler may see a need to shuffle them around.

If you are looking for a more specific answer, it would behoove you to research what scheduler your Linux kernel is using and how it schedules processes. Once you understand how it schedules them, it may be beneficial to play with configurations/flags so that it plays nicely with all your background heavy tasks. Keep in mind though, if you do anything too extreme you face huge risks of starving processes/threads, extremely long run times, or just poor performance in general.

Upvotes: 1

Related Questions