Setting core affinity improves performance?

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
cwscribner
Posts: 316
Joined: Thu Mar 31, 2011 9:54 am
Location: Patten, ME
Contact:

Setting core affinity improves performance?

Post by cwscribner »

Hi all.

I recently migrated XI to a new server with 16G RAM and an 8 core CPU. The load was out of control, often hitting 20.0 if not higher, so I set process affinity in hopes that it would help. I gave httpd cores 7&8, nagios and npcd cores 1-3, and mysql uses cores 4-6. It seems like its improved performance but I don't know how I can definitively check that. Any thoughts? Is this all in my head?
Last edited by cwscribner on Tue Oct 18, 2011 10:53 am, edited 1 time in total.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Setting core affinity improves performance?

Post by mguthrie »

I would be interested in getting the notes on how you set that up. That's something we haven't tested before.

I'm currently running some benchmark tests on a smaller scale with a single CPU to see what other tweaks can be done. One of the ways that I'm testing changes is to use the Graph Explorer component, and then I use the Time-Stacked view where I overlay the last 3 days for the localhost->Current Load. I make a change, let it run for a day, and come back and compare it with the days before. It's not an exact science, but it gives a decent idea of what makes a difference.
cwscribner
Posts: 316
Joined: Thu Mar 31, 2011 9:54 am
Location: Patten, ME
Contact:

Re: Setting core affinity improves performance?

Post by cwscribner »

I just make the changes using htop as the root user. After you open htop, highlight a process, then hit "a" to see the cores that the process is able to use. You can check/uncheck them with the space bar. I just set the affinity arbitrarily as I wasn't sure which processes would use the most. I assumed that nagios/npcd would be tier 1, mysql would be tier 2, and apache/httpd would be tier 3 at a distance. So I gave nagios/npcd cores 1-3, mysql cores 4-6, and apache cores 7-8.
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Setting core affinity improves performance?

Post by mguthrie »

Cool stuff!

As an FYI, mysqld and httpd are #1 and #2 for CPU if mysql is not offloaded, after that it's dependent on the environment.
cwscribner
Posts: 316
Joined: Thu Mar 31, 2011 9:54 am
Location: Patten, ME
Contact:

Re: Setting core affinity improves performance?

Post by cwscribner »

So just a quick note, I don't think the CPU affinity is retained after restarting the process or the server. I restarted mine yesterday and all the affinities I set are gone. There may be a more permanent way to do it. Possibly force a PID and then set the affinity on that PID, or perhaps a configuration file somewhere? I'm not well versed in resource manipulation...
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Setting core affinity improves performance?

Post by jsmurphy »

hmmm this is a pretty interesting read and this article has some info on permanently setting affinity: http://www.linuxjournal.com/article/6799?page=0,1. I wonder if this would have any benefit in a virtualised environment... highly unlikely... now that I think about it, depends on the Hypervisor I suppose.
Locked