2.1. Planning

Since Pgpool-II is a tool to manage PostgreSQL, we need to decide how to deploy them first. In addition, it is possible to have multiple number of Pgpool-II installations to enhance the availability of Pgpool-II itself. We need to plan how many installations of Pgpool-II is required before hand. In this chapter we first discuss the running mode of PostgreSQL then the deployment of Pgpool-II.

2.1.1. Clustering mode of PostgreSQL

It is possible to have more than or equal to one installation of PostgreSQL, it is common to have more than 2 installations of it because if there's only one installation, the whole database system goes down if the PostgreSQL is not available. When we use two or more PostgreSQL servers, it is necessary to sync the databases in some way. We call the methods of syncing databases as "clustering running mode". The most popular mode ever used is "streaming replication mode". Unless there's necessity to have special consideration, it is recommended to use the streaming replication mode. See Section 3.3.2 for more details of running mode.

The next thing we need to consider is how many PostgreSQL installations we want. If there are two, we can continue to operate the database system. However it is not uncommon to use more than two PostgreSQL if you want to employ read query load balancing by running multiple read quires on multiple servers. Pgpool-II provides rich variety of options to tune load balancing. See Section 5.8 for more details.

Since it is possible to add PostgreSQL servers later on in Pgpool-II, two PostgreSQL can be a good starter for you.

2.1.2. Deployment of Pgpool-II

Although it is possible to use only one Pgpool-II, we recommend to use more than 1 Pgpool-II to avoid whole database unavailability due to the Pgpool-II being down. Multiple Pgpool-II work together and monitor each other. One of them is called "leader" and it has a virtual IP. Clients do not need to aware that there are multiple Pgpool-II because they always access the same VIP. (See Section 4.1 for watchdog). If one of Pgpool-II goes down, other Pgpool-II takes over the leader role.

Since it is not allowed to have multiple leader, watchdog votes to decide a new leader. If there are even number of Pgpool-II, it is impossible to decide the new leader by voting. Thus we recommend to deploy Pgpool-II in more than or equal to 3 odd numbers.

Please note that it is possible to have Pgpool-II and PostgreSQL on a same server. For example you can have only three servers to run both Pgpool-II and PostgreSQL on each of it.

You can find a production level detailed example using three Pgpool-II and two PostgreSQL in streaming replication mode in Section 8.2 for those who want to have a production level Pgpool-II installation today.