pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: David Gauthier <davegauthierpg@gmail.com>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Estimated resources for a 500 connections instance (VM)
Date: Wed, 08 Apr 2020 09:39:15 +0200
Message-ID: <61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at> (raw)
In-Reply-To: <CAMBRECC+1Z2bguc9cKnFUsJu2KoPeHjnr6P6NeqK1MRCZHoTOQ@mail.gmail.com>
References: <CAMBRECDfz6Zjzy0Bitf+WhKcYZ+j=rvJDe7JN5tZ8etu7E-J8Q@mail.gmail.com>
	<3fd51f3222a35e227484afae34796d3f4f667567.camel@cybertec.at>
	<CAMBRECC+1Z2bguc9cKnFUsJu2KoPeHjnr6P6NeqK1MRCZHoTOQ@mail.gmail.com>

On Tue, 2020-04-07 at 15:51 -0400, David Gauthier wrote:
> But for my edification, is it roughly true that 2 connections working with the DB 100%
> of the time is equivalent to 20 connections @ 10% = 200 connections @ 1 % (if you know what I mean) ?

Roughly, yes.
There is a certain overhead, as each query has to take a snapshot of the
database, which has to consider all active connections.

But the main problem is that you have no way to ensure that all those
idle connections stay idle.

Imagine that most of these sessions issue short statements
against "table1".  There are also some longer SELECTs.
No problem so far.
Now along comes a statement that blocks the table for a very short
time, like a CREATE INDEX CONCURRENTLY.
Unfortunately, that ACCESS EXCLUSIVE lock has to wait for one of
the longer SELECTs to finish.
Now all those moderately short statements cannot run any more, but
they have to queue behind the ACCESS EXCLUSIVE lock. For a
while, nothing happens.  Then, as soon as the CREATE INDEX CONCURRENTLY
has got its lock, done its work and finished, all hell breaks loose,
because all sessions start executing their statements at the same time.

I have seen databases servers go down because of such events, and
the problem is the high number of connections, even if they are idle
most of the time.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com






view thread (9+ messages)

Message-ID: <61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at>
Permalink:  ../61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at/
Also on:    postgresql.org/message-id/61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, davegauthierpg@gmail.com
  Subject: Re: Estimated resources for a 500 connections instance (VM)
  In-Reply-To: <61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at>
  References: <CAMBRECDfz6Zjzy0Bitf+WhKcYZ+j=rvJDe7JN5tZ8etu7E-J8Q@mail.gmail.com> <3fd51f3222a35e227484afae34796d3f4f667567.camel@cybertec.at> <CAMBRECC+1Z2bguc9cKnFUsJu2KoPeHjnr6P6NeqK1MRCZHoTOQ@mail.gmail.com> <61be363b9bb9e3e326bce538e9b5f480bf232103.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox