Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 48E9A632F00 for ; Wed, 7 Apr 2010 19:56:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 44907-02 for ; Wed, 7 Apr 2010 22:56:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-yw0-f184.google.com (mail-yw0-f184.google.com [209.85.211.184]) by mail.postgresql.org (Postfix) with ESMTP id 9605C632EFE for ; Wed, 7 Apr 2010 19:56:32 -0300 (ADT) Received: by ywh14 with SMTP id 14so796803ywh.15 for ; Wed, 07 Apr 2010 15:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:content-type :content-transfer-encoding; bh=p/MHqEYgHO8BucR2GkLH+PiZEgPZrzcL0MxU4NUiJFA=; b=OwAQmeZbmvYP7YXgLFsxCWMP8/poiZYIYwV5FjgSxtDSogmihoed7Jmh5CjVjmFCrn bBujgLdi1JmSSdfvftsf8ltcYoBfAB3wi5xHqSeJwGKr4E6btpNYJde6dz3qNek3prEK zWHRr5+GPeMxa1Mgps97pLUL0kMdJrKj2+I+U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=I33NsYRKO+GxnuD8+oAEtvsNHTO5zb2L8mEoGGvexOzcanI3dQtY9dle+Y0HS+iJ6G 7Qw1gprXjOZdWbm/1bPo7nqjudVGoN/ANNaYql52YzXndfOFkByjSEPHnowjVuDSfKj9 HnjgBQqeJ4ztI42Jvu7gYIwH1w2Kl0H1qg9C4= MIME-Version: 1.0 Received: by 10.151.111.5 with HTTP; Wed, 7 Apr 2010 15:56:11 -0700 (PDT) In-Reply-To: <4BBCFB12.1010306@emolecules.com> References: <4BBCFB12.1010306@emolecules.com> From: David Rees Date: Wed, 7 Apr 2010 15:56:11 -0700 Received: by 10.150.7.15 with SMTP id 15mr10021345ybg.254.1270680991271; Wed, 07 Apr 2010 15:56:31 -0700 (PDT) Message-ID: Subject: Re: Occasional giant spikes in CPU load To: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.049 tagged_above=-10 required=5 tests=AWL=-1.050, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201004/78 X-Sequence-Number: 38328 On Wed, Apr 7, 2010 at 2:37 PM, Craig James wr= ote: > Most of the time Postgres runs nicely, but two or three times a day we ge= t a > huge spike in the CPU load that lasts just a short time -- it jumps to 10= -20 > CPU loads. =A0Today it hit 100 CPU loads. =A0Sometimes days go by with no= spike > events. =A0During these spikes, the system is completely unresponsive (yo= u > can't even login via ssh). You need to find out what all those Postgres processes are doing. You might try enabling update_process_title and then using ps to figure out what each instance is using. Otherwise, you might try enabling logging of commands that take a certain amount of time to run (see log_min_duration_statement). > I managed to capture one such event using top(1) with the "batch" option = as > a background process. =A0See output below - it shows 19 active postgress > processes, but I think it missed the bulk of the spike. Looks like it. The system doesn't appear to be overloaded at all at that p= oint. > 8 CPUs, 8 GB memory > 8-disk RAID10 (10k SATA) > Postgres 8.3.0 Should definitely update to the latest 8.3.10 - 8.3 has a LOT of known bugs= . > Fedora 8, kernel is 2.6.24.4-64.fc8 Wow, that is very old, too. > Diffs from original postgres.conf: > > max_connections =3D 1000 > shared_buffers =3D 2000MB > work_mem =3D 256MB work_mem is way too high for 1000 connections and 8GB ram. You could simply be starting up too many postgres processes and overwhelming the machine. Either significantly reduce max_connections or work_mem. > max_fsm_pages =3D 16000000 > max_fsm_relations =3D 625000 > synchronous_commit =3D off You are playing with fire here. You should never turn this off unless you do not care if your data becomes irrecoverably corrupted. > top - 11:24:59 up 81 days, 20:27, =A04 users, =A0load average: 0.98, 0.83= , 0.92 > Tasks: 366 total, =A020 running, 346 sleeping, =A0 0 stopped, =A0 0 zombi= e > Cpu(s): 30.6%us, =A01.5%sy, =A00.0%ni, 66.3%id, =A01.5%wa, =A00.0%hi, =A0= 0.0%si, > =A00.0%st > Mem: =A0 8194800k total, =A08118688k used, =A0 =A076112k free, =A0 =A0 = =A0 36k buffers > Swap: =A02031608k total, =A0 169348k used, =A01862260k free, =A07313232k = cached System load looks very much OK given that you have 8 CPUs. > PID USER =A0 =A0 =A0PR =A0NI =A0VIRT =A0RES =A0SHR S %CPU %MEM =A0 =A0TIM= E+ =A0COMMAND > 18972 postgres =A020 =A0 0 2514m =A011m 8752 R =A0 11 =A00.1 =A0 0:00.35 = postmaster > 10618 postgres =A020 =A0 0 2514m =A012m 9456 R =A0 =A09 =A00.2 =A0 0:00.5= 4 postmaster > 10636 postgres =A020 =A0 0 2514m =A011m 9192 R =A0 =A09 =A00.1 =A0 0:00.4= 5 postmaster > 25903 postgres =A020 =A0 0 2514m =A011m 8784 R =A0 =A09 =A00.1 =A0 0:00.2= 1 postmaster > 10626 postgres =A020 =A0 0 2514m =A011m 8716 R =A0 =A06 =A00.1 =A0 0:00.4= 5 postmaster > 10645 postgres =A020 =A0 0 2514m =A012m 9352 R =A0 =A06 =A00.2 =A0 0:00.4= 2 postmaster > 10647 postgres =A020 =A0 0 2514m =A011m 9172 R =A0 =A06 =A00.1 =A0 0:00.5= 1 postmaster > 18502 postgres =A020 =A0 0 2514m =A011m 9016 R =A0 =A06 =A00.1 =A0 0:00.2= 3 postmaster > 10641 postgres =A020 =A0 0 2514m =A012m 9296 R =A0 =A05 =A00.2 =A0 0:00.3= 6 postmaster > 10051 postgres =A020 =A0 0 2514m =A013m =A010m R =A0 =A04 =A00.2 =A0 0:00= .70 postmaster > 10622 postgres =A020 =A0 0 2514m =A012m 9216 R =A0 =A04 =A00.2 =A0 0:00.3= 9 postmaster > 10640 postgres =A020 =A0 0 2514m =A011m 8592 R =A0 =A04 =A00.1 =A0 0:00.5= 2 postmaster > 18497 postgres =A020 =A0 0 2514m =A011m 8804 R =A0 =A04 =A00.1 =A0 0:00.2= 5 postmaster > 18498 postgres =A020 =A0 0 2514m =A011m 8804 R =A0 =A04 =A00.1 =A0 0:00.2= 2 postmaster > 10341 postgres =A020 =A0 0 2514m =A013m =A0 9m R =A0 =A02 =A00.2 =A0 0:00= .57 postmaster > 10619 postgres =A020 =A0 0 2514m =A012m 9336 R =A0 =A01 =A00.2 =A0 0:00.3= 8 postmaster > 15687 postgres =A020 =A0 0 2321m =A035m =A035m R =A0 =A00 =A00.4 =A0 8:36= .12 postmaster Judging by the amount of CPU time each postmaster as accumulated, they are all fairly new processes. How many pg proceses of the ~350 currently running are there? -Dave