agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Idle connections / sessions
5+ messages / 4 participants
[nested] [flat]

* Idle connections / sessions
@ 2018-12-12 09:37 Oygun Josef <josef.oygun@scania.com>
  2018-12-12 09:55 ` Re: Idle connections / sessions Thomas Kellerer <spam_eater@gmx.net>
  2018-12-12 10:02 ` Re: Idle connections / sessions Fabio Pardi <f.pardi@portavita.eu>
  0 siblings, 2 replies; 5+ messages in thread

From: Oygun Josef @ 2018-12-12 09:37 UTC (permalink / raw)
  To: pgadmin-support@postgresql.org <pgadmin-support@postgresql.org>; pgadmin-support@lists.postgresql.org <pgadmin-support@lists.postgresql.org>; pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>; pgsql-sql; pgsql-general@postgresql.org <pgsql-general@postgresql.org>

Hi,

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.

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


Josef Oygun

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Idle connections / sessions
  2018-12-12 09:37 Idle connections / sessions Oygun Josef <josef.oygun@scania.com>
@ 2018-12-12 09:55 ` Thomas Kellerer <spam_eater@gmx.net>
  1 sibling, 0 replies; 5+ messages in thread

From: Thomas Kellerer @ 2018-12-12 09:55 UTC (permalink / raw)
  To: pgsql-jdbc@postgresql.org; +Cc: pgadmin-support@postgresql.org; pgsql-sql; pgsql-general@postgresql.org

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-T...

> 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





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Idle connections / sessions
  2018-12-12 09:37 Idle connections / sessions Oygun Josef <josef.oygun@scania.com>
@ 2018-12-12 10:02 ` Fabio Pardi <f.pardi@portavita.eu>
  2018-12-12 10:10   ` Re: Idle connections / sessions Thomas Poty <thomas.poty@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Fabio Pardi @ 2018-12-12 10:02 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi Josef,

please avoid cross posting to multiple lists.

I m not a developer, but I think that if you do not want idle connections, you should terminate them on the side they have been created.

If your application leaves the connection open, then you will notice idle connections on Postgres when not in use.

regards,

fabio pardi


On 12/12/2018 10:37, Oygun Josef wrote:
>
> Hi,
>
>  
>
> 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.
>
>  
>
> It is both PGAdmin and the PostgreSQL JDBC Driver that leaves open idle connections.
>
>  
>
>  
>
> *Josef Oygun*
>
>  
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Idle connections / sessions
  2018-12-12 09:37 Idle connections / sessions Oygun Josef <josef.oygun@scania.com>
  2018-12-12 10:02 ` Re: Idle connections / sessions Fabio Pardi <f.pardi@portavita.eu>
@ 2018-12-12 10:10   ` Thomas Poty <thomas.poty@gmail.com>
  2018-12-12 18:26     ` Re: Idle connections / sessions Thomas Poty <thomas.poty@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Thomas Poty @ 2018-12-12 10:10 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hi Josef,

pg_terminator may help you.

thomas

Le mer. 12 déc. 2018 à 11:02, Fabio Pardi <f.pardi@portavita.eu> a écrit :

> Hi Josef,
>
> please avoid cross posting to multiple lists.
>
> I m not a developer, but I think that if you do not want idle connections,
> you should terminate them on the side they have been created.
>
> If your application leaves the connection open, then you will notice idle
> connections on Postgres when not in use.
>
> regards,
>
> fabio pardi
>
>
> On 12/12/2018 10:37, Oygun Josef wrote:
>
> Hi,
>
>
>
> 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.
>
>
>
> It is both PGAdmin and the PostgreSQL JDBC Driver that leaves open idle
> connections.
>
>
>
>
>
> *Josef Oygun*
>
>
>
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Idle connections / sessions
  2018-12-12 09:37 Idle connections / sessions Oygun Josef <josef.oygun@scania.com>
  2018-12-12 10:02 ` Re: Idle connections / sessions Fabio Pardi <f.pardi@portavita.eu>
  2018-12-12 10:10   ` Re: Idle connections / sessions Thomas Poty <thomas.poty@gmail.com>
@ 2018-12-12 18:26     ` Thomas Poty <thomas.poty@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Thomas Poty @ 2018-12-12 18:26 UTC (permalink / raw)
  To: Oygun Josef <josef.oygun@scania.com>; +Cc: pgsql-general@lists.postgresql.org

Sorry but i don't know (i am not familiar with aws) ....
Maybe this will  help: If you want pg_terminator can run on postgresql
server.

Regards
Thomas

Le mer. 12 déc. 2018 à 12:20, Oygun Josef <josef.oygun@scania.com> a écrit :

> Hi,
>
>
>
> Sorry for that!
>
>
>
> Thank you for the answers, this is good but do you know if there is a way
> do to it through AWS console with some kind of configuration instead?
>
>
>
> Reason for that is the we use terraform scripts to create and keep state
> of our instances so pg_terminator would require me to add every new db
> props to it.
>
>
>
> /Josef
>
>
>
>
>
> *Från:* Thomas Poty [mailto:thomas.poty@gmail.com]
> *Skickat:* den 12 december 2018 11:11
> *Till:* pgsql-general@lists.postgresql.org
> *Ämne:* Re: Idle connections / sessions
>
>
>
> Hi Josef,
>
>
>
> pg_terminator may help you.
>
>
>
> thomas
>
>
>
> Le mer. 12 déc. 2018 à 11:02, Fabio Pardi <f.pardi@portavita.eu> a écrit :
>
> Hi Josef,
>
> please avoid cross posting to multiple lists.
>
> I m not a developer, but I think that if you do not want idle connections,
> you should terminate them on the side they have been created.
>
> If your application leaves the connection open, then you will notice idle
> connections on Postgres when not in use.
>
> regards,
>
> fabio pardi
>
> On 12/12/2018 10:37, Oygun Josef wrote:
>
> Hi,
>
>
>
> 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.
>
>
>
> It is both PGAdmin and the PostgreSQL JDBC Driver that leaves open idle
> connections.
>
>
>
>
>
> *Josef Oygun*
>
>
>
>
>
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2018-12-12 18:26 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 09:37 Idle connections / sessions Oygun Josef <josef.oygun@scania.com>
2018-12-12 09:55 ` Thomas Kellerer <spam_eater@gmx.net>
2018-12-12 10:02 ` Fabio Pardi <f.pardi@portavita.eu>
2018-12-12 10:10   ` Thomas Poty <thomas.poty@gmail.com>
2018-12-12 18:26     ` Thomas Poty <thomas.poty@gmail.com>

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