Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have access to a CentOS 6 web server (a PHP/MySQL forum) running Apache 2.2.15 and MySQL 5.1.52. This box has dual oct-core Xeons.

What I find looking over the CPU graphs is that the first two cores (0 and 1) hit 90% usage whilst the other fourteen are only reaching 30-40% usage. Core 8, which I believe is the first core of the second processor, see's high usage (up to 90%) but then as mentioned, all others are low.

Apache fires up about 20 processes and I suspect in its default state, it can't understand, and make use of all the cores naturally. This should be the kernels job I think (can someone confirm?). However, with those cores maxing out, there is a noticable performance drop despite spare RAM and disk I/O.

Is there something I can tweak in Apache to "make it aware" of all the other cores, or perhaps a kernel peramater to assign certain process to certain cores? Can I exclude cores 0 and 1 for example, from being used for Apache and MySQL?

share|improve this question
2  
A lot of additional information would help. Are you serving static pages? Dynamic pages? What does the network traffic level look like? How is apache tuned currently? –  David Schwartz Jan 1 '12 at 13:29
    
Just as note: it does NOT have dual oct core xeons - therea re none. It has dual QUAD core xeons with Hyperthreading, where every core shows as 2 that can sometimes not do the same thing at the same time. NOT the same. –  TomTom Jan 28 '12 at 11:15

3 Answers 3

up vote 2 down vote accepted

Tunning process affinity with taskset

e.g assign current process to cpu-core 0,1,3

$taskset -cp 0,1,3 $$

pid 21698's current affinity list: 0-7

pid 21698's new affinity list: 0,1,3

Isolate CPUs to run particular process only. Kernel parameter “isolcpus” can isolate particular CPUs from doing other tasks. Together with taskset, you can have particular CPUs to run designated tasks only. E.g put “isolcpus=2,3 “ in grub.conf will isolate CPU 2 and 3.

http://honglus.blogspot.com/2011/03/tune-interrupt-and-process-cpu-affinity.html

share|improve this answer

Not all application traffic is highly paralellizeable. We have a web-application internally that is resolutely single-threaded, even when running on a 24-core monster. In our case, the web-server will happily use as many cores as we throw at it for static serving; but when bound to a specific app-server it stays with one.

If we look at per-core usage when that single-threaded process is running each core will be running at 100*(1/n) percentage. The kernel is moving the load across multiple cores as it should, but only 100% of one processor's capacity is ever used.

In our case, we are running a LAMx stack. Where (x) is undefined in this answer. As it turns out, what (x) represents is rather important. So yes, ability to use lots of cores is dependent upon all steps in the stack, not just the LAM parts.

share|improve this answer
2  
This is known as "Amdahl's Law". See Wikipedia –  mpez0 Jan 4 '12 at 15:39
    
SO, are you suggesting that in my case (x = PHP), we should perhaps review the PHP configuration? –  jwbensley Jan 28 '12 at 10:48
    
And possibly programming. There are some thing on the programming side that can make the execution effectively single threaded. a "slow" ASp application ceoms to my mind ages ago that used one database connection centrally stored and pages waited in line for access to it. –  TomTom Jan 28 '12 at 11:17
    
Thanks for the info TomTom. What I am wondering is, the 20 odd Apache threads that are fired up, is there any way to have them run on individual cores. As per my original post, core 1 on chip 1 is at 90% and 2,3 and 4 are at around 30% perhaps. All those Apache instances and they just huddle round one core. I mentioned PHP, as I understand it, each Apache instance calls PHP; So, by spreading the Apache instances across all the cores, I would effectively spread out PHP, if this is at all possible, right? –  jwbensley Jan 28 '12 at 11:33

It is, indeed, kernel's job to schedule tasks. In a multi core environment, at times (but not always), it happens that kernel assigns job to all the cores but on one or two cores all the heavy duty processes like apache gets assigned.
Ideally your kernel should already be aware that there are multiple cores in your machine. Still run the following to confirm as superuser:

dmidecode|grep Core

On my dual core machine it says:

Version: Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz
Core Count: 2
Core Enabled: 2
share|improve this answer
    
Hi there, thanks for the reply :) I haven't got dmidecode but 'cat /proc/cpuino' shows 16 cores (0-15) each at 3Ghz as expected :) –  jwbensley Jan 4 '12 at 14:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.