Postgresql – High Availability for postgresql

high-availabilitylinuxpostgresql

I'm new in PostgreSQL database. Recently our developer needed to do some upgrades in our systems.

Because of that we are planning to implement some method in order to implement database failover.

Based on my reading from postgresql wiki here, we are trying to implement either warm standby or hot standby. So my questions are:

  1. What are major differences between them?
  2. Which one is better?
  3. Is there any other method that we can consider for making high availability in our Postgres databases?

Best Answer

1a. Warm standby is a "live", incremental backup fed with complete blocks of changes (wal segments) 16 mb each, that are send to the standby node once they're filled. You cannot query a warm standby node. 16 mb of changes (by default) can mean a lot of transactions, should the master fail, they'll be lost.

1b. Hot Standby. (also a "live" incremental backup) .small changes are send to the slave (wal records, which are tiny parts of a wal segment). You can query (read only) the hot standby node. The window for lost transactions should the master fail is very tiny. There are synchronous and asynchronous hot standby nodes, a synchronous node will force the master to wait for it to confirms the application of changes and then the master will commit the transaction.In asynchronous replication the master sends the wal records and does not wait for confirmation. The former requires a very reliable and fast link between the master and the slave,also adds overhead to the master but guarantees no data loss.

Regarding incremental backups: 1. You take a base copy of your whole database installation. 2. Ship it to the slave. 3. Configure it to catch up for changes.

Streaming Replication (hot standby) is the winner here. I personally prefer asynchronous replication as it does not impose a considerable burden on the master and the replication lag is very small (a couple of seconds in many cases)

One complement to this setup is pg-pool. It acts as a proxy between the application and the servers participating in a replication configuration like the one described above, it has load balancing and parallel query capabilities. It's able also to provide automatic failover. http://www.pgpool.net/pgpool-web/contrib_docs/simple_sr_setting/index.html