Обсуждение: very high CPU usage in "top", but not in "mpstat"

Поиск
Список
Период
Сортировка

very high CPU usage in "top", but not in "mpstat"

От
"Cyrille Bonnet"
Дата:

Hello all,

 

We are using Postgres 7.3 with JBoss 3.2.3 on a Linux Fedora 1.0 box.

 

When I am looking at CPU activity with “top”, I often see something like:

 

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU COMMAND

14154 postgres  25   0  3592 3592  2924        R    99.1      0.3        93:53   0 postmaster

 

At the same time, “mpstat” gives me something like:

 

11:27:21 AM  CPU   %user   %nice %system   %idle    intr/s

11:27:21 AM  all       2.99      0.00   18.94         78.08    105.94

 

The system is not visibly slow and response time is satisfactory. Sometimes, the CPU usage drops to 1 or 2%, but not for long usually. Also I have checked the number of open connections to Postgres and there are only 5 (maximum is set to the default: 32).

 

Should I be worried that Postgres is eating up 99% of my CPU??? Or is this *expected* behaviour?

 

Please note that I am a developer, not a system administrator, so maybe I misunderstand the usage of “top” here.

 

Any help will be appreciated.

 

Cyrille.

Re: very high CPU usage in "top", but not in "mpstat"

От
Tom Lane
Дата:
"Cyrille Bonnet" <cyrille@3months.com> writes:
> Should I be worried that Postgres is eating up 99% of my CPU??? Or is this
> *expected* behaviour?

It's not expected, unless you are running some very long-running query.

The conflict between what top says and what mpstat says is strange; I
wonder if you might have a buggy version of one of them?  You should
probably check some other tools (try "vmstat 1" for instance) to see if
you can get a consensus on whether the CPU is maxed out or not ...

            regards, tom lane

Re: very high CPU usage in "top", but not in "mpstat"

От
Paul Tuckfield
Дата:
I'm guessing you have a 4 cpu box:
1 99 percent busy process on a 4 way box == about 25% busy overall.


On May 5, 2004, at 6:03 AM, Tom Lane wrote:

> "Cyrille Bonnet" <cyrille@3months.com> writes:
>> Should I be worried that Postgres is eating up 99% of my CPU??? Or is
>> this
>> *expected* behaviour?
>
> It's not expected, unless you are running some very long-running query.
>
> The conflict between what top says and what mpstat says is strange; I
> wonder if you might have a buggy version of one of them?  You should
> probably check some other tools (try "vmstat 1" for instance) to see if
> you can get a consensus on whether the CPU is maxed out or not ...
>
>             regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 8: explain analyze is your friend
>