Accessing multiple servers using the same host and port
We will now show you one simple, yet important, application of the previous recipe, Setting up a connection pool. In that recipe, you learned how to reuse connections with PgBouncer, thus reducing the cost of disconnecting and reconnecting.
Here, we will demonstrate another way to use PgBouncer – one instance can connect to databases hosted by different database servers at the same time. These databases can be on separate hosts and can even have different major versions of PostgreSQL!
Getting ready
Suppose we have three database servers, each one hosting one database. All you need to know beforehand is the connection string for each database server.
More complex arrangements are possible, but those are left to you as an exercise.
Before you try this recipe, you should have already gone through the previous recipe. These two recipes have many steps in common, but we’ve kept them separate because...