Thread: keepalive problem with libpg connection
Hi,
I am writing my own connection pool for libpq's connection.
My goal is to try to reduce the amount of time spent in opening and closing socket. However, I see that Postgres would close my connection after every so often.
What is the best solution for that? Should I regularly send some "Select 1" to keep the connection alive or is there a better way to write a connection pool for libpq?
Any suggestion will be greatly appreciated.
JB
I am writing my own connection pool for libpq's connection.
My goal is to try to reduce the amount of time spent in opening and closing socket. However, I see that Postgres would close my connection after every so often.
What is the best solution for that? Should I regularly send some "Select 1" to keep the connection alive or is there a better way to write a connection pool for libpq?
Any suggestion will be greatly appreciated.
JB
On Tue, Aug 11, 2009 at 3:56 AM, Juan Backson<juanbackson@gmail.com> wrote: > Hi, > > I am writing my own connection pool for libpq's connection. > > My goal is to try to reduce the amount of time spent in opening and closing > socket. However, I see that Postgres would close my connection after every > so often. it's not postgres, most likely someone in the middle is closing inactive connections, typically after 3-5 minutes. check out the keepalive settings in postgresql.conf to handle this on the tcp level (better than throwing a select 1). merlin