Thread: Running on multiple core server

Running on multiple core server

From
Jason Tan Boon Teck
Date:
Hi,


I just bought a DELL Xeon with Quad Cores and installed it with Debian
Stable. I tested this server to run my web application written with
PHP5 with PostgreSQL 8.3 as the rdbms.

While retrieving a complex report on client machine using a web
browser, that took a few minutes, I ran htop on the server which shows
the CPU core's activities. It showed Apache2 and PostgreSQL working
furiously, but, only sharing a single core. The other 3 cores remained
idle.

However when I ran the query simultaneous from a 2nd client, it used
another core for this. And a 3rd core was used when I ran another
query from a 3rd client, running simultaneously.

Why doesn't the OS make use of the other 3 cores - assigning one to
Apache and another to PostgreSQL when only 1 client is querying?

uname -a shows
Linux  pcserver 2.6.26-2-686 #1 SMP Mon Aug 30 07:01:57 UTC 2010 i686 GNU/Linux

Is there anything I can do to tweak?


--
Jason Tan Boon Teck

Re: Running on multiple core server

From
Christian Ramseyer
Date:
On 10/13/2010 06:03 AM, Jason Tan Boon Teck wrote:
>
> Why doesn't the OS make use of the other 3 cores - assigning one to
> Apache and another to PostgreSQL when only 1 client is querying?
>

The scheduler in your Linux kernel decided that it was better to run
both these tasks on the same core. This may have advantages regarding
CPU register, cache or pipeline usage.

Usually, CPU processing power isn't the bottleneck in database
applications, I/O (i.e. how fast can be read from/written to storage)
tends to be the limiting factor. So it's quite likely that running on
two cores would either not improve the total runtime or even slow your
application down.

> Is there anything I can do to tweak?
>

Look for an utility named taskset, usually contained in the schedutils
package. You can use it to set the CPU affinity of processes to specific
CPUs, e.g.

taskset -c 3,4 -p a1,a2,a3 #--> your Apaches with pid a1-3 are now bound
to CPUs 3 & 4.

You'll need to RTFM a bit though to find out how/if it can deal with the
child processes Postgres spawns, I've never tried to do that (or
anything with this utility at all for that matter).

Hope that helps
Christian