Re: [PERFORM] Many connections lingering

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Slavisa Garic <sgaric(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: [PERFORM] Many connections lingering
Date: 2005-04-13 05:01:40
Message-ID: 3372.1113368500@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-performance

Greg Stark <gsstark(at)mit(dot)edu> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> This is a network-level issue: the TCP stack on your machine knows the
>> connection has been closed, but it hasn't seen an acknowledgement of
>> that fact from the other machine, and so it's remembering the connection
>> number so that it can definitively say "that connection is closed" if
>> the other machine asks.

> No, what Tom's describing is a different pair of states called FIN_WAIT_1 and
> FIN_WAIT_2. TIME_WAIT isn't waiting for a packet, just a timeout.

D'oh, obviously it's been too many years since I read Stevens ;-)

So AFAICS this status report doesn't actually indicate any problem,
other than massively profligate use of separate connections. Greg's
correct that there's some risk of resource exhaustion at the TCP level,
but it's not very likely. I'd be more concerned about the amount of
resources wasted in starting a separate Postgres backend for each
connection. PG backends are fairly heavyweight objects --- if you
are at all concerned about performance, you want to get a decent number
of queries done in each connection. Consider using a connection pooler.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Slavisa Garic 2005-04-13 05:09:03 Re: [PERFORM] Many connections lingering
Previous Message Ruby Yanto Dj 2005-04-13 04:51:39 Postgresql connection

Browse pgsql-performance by date

  From Date Subject
Next Message Slavisa Garic 2005-04-13 05:09:03 Re: [PERFORM] Many connections lingering
Previous Message Greg Stark 2005-04-13 03:27:09 Re: [PERFORM] Many connections lingering