Re: How to find the culprit in server load spikes?

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Moreno Andreo <moreno(dot)andreo(at)evolu-s(dot)it>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: How to find the culprit in server load spikes?
Date: 2015-07-22 17:18:48
Message-ID: CAMkU=1wAiJw=gsRszDCO0W0=Rrn-RKqmXcWfrg8R7kJ=qKh1Gg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, Jul 22, 2015 at 5:50 AM, Moreno Andreo <moreno(dot)andreo(at)evolu-s(dot)it>
wrote:

> Hi everyone,
> I host a Postgresql server on Ubuntu 12.04 and I am facing server load
> spikes (if I run top, it goes up to 25-30 on a 4-core system)...
> In some cases, I have to restart potgresql service because users call us
> complaining of the slowness, but in some cases I can leave things on their
> way and I see that after a bunch of minutes (about 5-10) the situations
> drops to the normality (0.50-2 load).
> The problem is, as in the most cases, the I/O, but I need a small hand to
> know some methods or tools that can help me to investigate who or what is
> causing me these spikes.
>

I always run systems starting out with logging cranked up to at least these
settings:

log_checkpoints = on
log_lock_waits = on
shared_preload_libraries = 'pg_stat_statements,auto_explain'
auto_explain.log_min_duration = '10s'
track_io_timing = on
log_autovacuum_min_duration = 1000
log_min_duration_statement = 1000 ## or less

In particular, you would want to see what the reported "sync" time is for
the checkpoint, and whether the slowness (as shown by the frequency of
statement min duration log events) is occurring in a pattern around the
beginning and end of a checkpoint.

I'd also set up vmstat to run continuously capturing output to a logfile
with a timestamp, which can later be correlated to the postgres log file
entries.

Cheers,

Jeff

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message domenico febbo 2015-07-23 11:37:29 Re: hyperthreadin low performance
Previous Message Kevin Grittner 2015-07-22 16:40:55 Re: How to find the culprit in server load spikes?