PostgreSQL failover using poolboy and epgsql

Viewed 715

I'm building an Erlang application that uses poolboy for connection pooling, and epgsql to talk to PostgreSQL.

I'd like to handle PostgreSQL failover, and I'm wondering what the best way to structure my application is.

Should I or can I:

  • Have one pool for each PG peer, and handle this above poolboy. That is: when I detect the original PG server is down, can I kill the pool? Is there an Erlang-idiomatic way to decide which pool is still alive?
  • Kill and restart the workers when I detect the PG server is down? Is there an idiomatic way to do this?
  • Have my workers failover from one PG server to the other?
  • Something else?
2 Answers
Related