Currently on the server side we use the default keepalive timeouts:

  • tcp_keepalives_idle=7200

  • tcp_keepalive_count=9

  • tcp_keepalives_interval=75

Note that you can set the client side keepalive timeouts to whatever values you wish. (see; the libpq configuration keys are the same as on the server side except that the tcp_ prefix is omitted from the configuration keys)

Even though TCP connections usually stay open for extended periods of time you should also make sure that your application(s) can reconnect since TCP connections are liable to break at times, usually at very inconvenient times at that. Also when reconnecting, you should make sure that your client always resolves the DNS address on connect since the underlying address will change during automatic fail over when a master node fails.

Did this answer your question?