Are many idle connections bad?

From: Craig James <cjames(at)emolecules(dot)com>
To: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Are many idle connections bad?
Date: 2015-07-25 14:50:35
Message-ID: CAFwQ8rcnqy4F4zDg+UX0A5dLbJ=4ifCDk7WN21y7w5HLtYxo7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

The canonical advice here is to avoid more connections than you have CPUs,
and to use something like pg_pooler to achieve that under heavy load.

We are considering using the Apache mod_perl "fast-CGI" system and perl's
Apache::DBI module, which caches persistent connections in order to improve
performance for lightweight web requests. Due to the way our customers are
organized (a separate schema per client company), it's possible that there
would be (for example) 32 fast-CGI processes, each of which had hundreds of
cached connections open at any given time. This would result in a thousand
or so Postgres connections on a machine with 32 CPUs.

But, Apache's fast-CGI mechanism allows you to specify the maximum number
of fast-CGI processes that can run at one time; requests are queue by the
Apache server if the load exceeds this maximum. That means that there would
never be more than a configured maximum number of active connections; the
rest would be idle.

So we'd have a situation where there there could be thousands of
connections, but the actual workload would be throttled to any limit we
like. We'd almost certainly limit it to match the number of CPUs.

So the question is: do idle connections impact performance?

Thanks,
Craig

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2015-07-25 15:04:51 Re: Are many idle connections bad?
Previous Message Mark Kirkwood 2015-07-25 04:10:30 Re: hyperthreadin low performance