How it works...

The goal of this recipe is to observe how quickly PgBouncer will switch from one server to another. HAProxy handles most of this work already, but PgBouncer has its own series of checks and safeguards that could artificially increase the failover time necessary to reassign server connections.

So the first thing we want to do is observe the process in action using the default settings. If we start an endless loop that simply reports the IP address of the server we're contacting, we accomplish two goals. The first is that we connect as quickly as possible to PgBouncer so that we have a timeline, and we also learn the IP address of the current BDR server, which should correspond to pgha1 or pgha2.

Then we will want a connection ...

Get PostgreSQL 12 High Availability Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.