Is a connection max lifetime useful in a connection pool?

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Is a connection max lifetime useful in a connection pool?
Date: 2021-02-21 18:05:03
Message-ID: CA+mi_8bnvpxHZtb6EgHSHY-xn29W8VJMzjPU3fiCOv1bfjrNuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I am designing and implementing a connection pool for psycopg3 [1][2].
Some of the inspiration is coming from HikariCP [3], a Java connection
pool.

One of the HikariCP configuration parameters is "maxLifetime", whose
description is: "This property controls the maximum lifetime of a
connection in the pool. [...] **We strongly recommend setting this
value, and it should be several seconds shorter than any database or
infrastructure imposed connection time limit.**" (bold is theirs,
default value is 30 mins).

When discussing the pool features in the psycopg mailing list someone
pointed out "what is the utility of this parameter? connections don't
rot, do they?"

Hikari is a generic connection pool, not one specific for Postgres. So
I'm wondering: is there any value in periodically deleting and
recreating connections for a Postgres-specific connection pool? Is a
MaxLifetime parameter useful?

Thank you very much,

-- Daniele

[1]: https://www.psycopg.org/articles/2021/01/17/pool-design/
[2]: https://github.com/psycopg/psycopg3/blob/connection-pool/psycopg3/psycopg3/pool.py
[3]: https://github.com/brettwooldridge/HikariCP

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2021-02-21 18:11:27 Re: Is a connection max lifetime useful in a connection pool?
Previous Message Tom Lane 2021-02-21 17:39:45 Re: Bizarre behavior of \w in a regular expression bracket construct