views:

257

answers:

3

Scenario

Multiple application servers host web services written in Java, running in SpringSource dm Server. To implement a new requirement, they will need to query a read-only PostgreSQL database.

Issue

To support redundancy, at least two PostgreSQL instances will be running. Access to PostgreSQL must be load balanced and must auto-fail over to currently running instances if an instance should go down. Auto-discovery of newly running instances is desirable but not required.

Research

I have reviewed the official PostgreSQL documentation on this issue. However, that focuses on the more general case of read/write access to the database. Top google results tend to lead to older newsgroup messages or dead projects such as Sequoia or DB Balancer, as well as one active project PG Pool II

Question

What are your real-world experiences with PG Pool II? What other simple and reliable alternatives are available?

+1  A: 

Have you looked at SQL Relay?

Grant Johnson
Not yet, but will have a look now. Thanks for the tip!
Eric J.
+1  A: 

PostgreSQL's wiki also lists clustering solutions, and the page on Replication, Clustering, and Connection Pooling has a table showing which solutions are suitable for load balancing.

I'm looking forward to PostgreSQL 9.0's combination of Hot Standby and Streaming Replication.

Stephen Denne
@Stephen: I have already had a look at PGPool. The other option for load balancing, PG Cluster, seems to have had their domain name taken over by someone pushing credit cards.
Eric J.
Ended up using PGPool II.
Eric J.
A: 

The standard solution for something like this is to look at Slony, Londiste or Bucardo. They all provide async replication to many slaves, where the slaves are read-only.

You then implement the load-balancing independent of this - on the TCP layer with something like HAProxy. Such a solution will be able to do failover of the read connections (though you'll still loose transaction visibility on a failover, and have to start new transaction on the new slave - but that's fine for most people)

Then all you have left is failover of the master role. There are supported ways of doing it on all these systems. None of them are automatic by default (because automatic failover of a database master role is really dangerous - consider the situation you are in once you've got split brain), but they can be automated easily if the requirement needs this for the master as well.

Magnus Hagander