Обсуждение: Re: Idle connections / sessions

Поиск
Список
Период
Сортировка

Re: Idle connections / sessions

От
Thomas Kellerer
Дата:
Oygun Josef schrieb am 12.12.2018 um 10:37:
> Is it possible to terminate idle connections/sessions automatically
> through a timeout in AWS or do I need to run a periodical cron job
> for this?
> 
> Postgres version: 9.6.6 Instance: db.t2.micro RAM : 1GB
> 
> We are running a microservice architecture using docker with
> kubernetes and I can see that every pod on every node that has
> connected to the DB still has a idle connection as long as the node
> is still active even.

An "idle" connection isn't really a problem. 

Long running "idle in transaction" session are a problem however. 

To cope with them, you could use idle_in_transaction_timeout: 

    https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT

> It is both PGAdmin and the PostgreSQL JDBC Driver that leaves open
> idle connections.

The JDBC driver does not leave any connections "open" or "idle"
It's the application that uses the driver that fails to close them. 

Maybe you need to configure your connection pool to release connections when they are idle.

Thomas