Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've configured postgres stand by replication using 1 master and 2 slaves.

Master and slave1 are located in USA datacenter while slave2 is located in a datacenter in London.

Is there any way of forcing all SELECT operations of the application that is running the London datacenter always use the slave2 to avoid network latency ?

Thanks, Lucas

share|improve this question
Since you've said nothing about the applications, their configuration, how the connection pooling is managed, etc, it's rather hard to say. – Craig Ringer Nov 9 '12 at 13:22
ok, sorry. The pool in configured in Glassfish. The application is based on hibernate. – user1096025 Nov 11 '12 at 23:25

Several ways come to mind:

  • Change the hostname/IP address the London-deployed apps are configured to connect to, so they connect to the London DBs

  • Use split-brained DNS to make the same host name resolve to a different IP address for servers in the London network, so they transparently connect to the desired Pg server

  • Use router rules to rewrite traffic, so the London apps think they're talking to the US servers but get redirected to the London ones. Your app admins will hate you for this if you do it, as it's a nightmare for anyone who doesn't know it's happening to debug.

  • Use a local PgBouncer or PgPool-II to redirect traffic

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.