Setting up a connection pool
AĀ connection poolĀ is a term that's used for aĀ collectionĀ of already-connected sessions that can be used to reduce the overhead of connection and reconnection.
There are various ways by which connection pools can be provided, depending on the software stack in use. The best option is to look at the server-side connection pool software because that works for all connection types, not just within a single software stack.
In this recipe, we're going to look atĀ PgBouncer, which isĀ designedĀ as a very lightweight connection pool. Its name comes from the idea that the pool can be paused and resumed to allow the server to be restarted orĀ bounced.
Getting ready
First of all, decide where you're going to store the PgBouncer parameter files, log files, and PID files. PgBouncer can manage more than one database server's connections at the same time, though that probably isn't wise for simple...