[pgpool-general: 2906] Re: Scenario for PgPool

Tatsuo Ishii ishii at postgresql.org
Fri Jun 6 08:14:33 JST 2014

> Hi,
> I'm new to PgPool, and read the docs. Not too sure I've got it all, so I'm
> asking to you guys help me understand.
> Today I have a web_app running Django in one server (webapp1) w/ PostreSQL
> DB on other machine (db_server1 - same network).
> My intention is to have replication (and if possible also load balance).
> I already have another machine with the very same configuration as the one
> running Postgres (db_server2).
> The idea was: Install Postgres in db_server2, and PgPool in both db_server1
> and db_server2
> Is this the way it should be? Which db_server should I point Django to? In
> case the pg_pool server I'm poiting to goes down, is there any
> configuration that can point to multiple servers?

I assume db_server1 and db_server2 are on the same network. In this
case you could have two pgpool instances (say pgpool_1 and pgpool_2),
each on db_server1 and db_server2 and enable watchdog so that your app
points to the virtual IP specified by the watchdog configuration. If
pgpool_1 goes down, pgpool_2 should notice it and takes over the
"master pgpool" role, inherits the VIP.

> Or pgPool should be running on webapp1?
> My doubt is because I plan to have webapp2 .. webappN as I need to grow...
> And in this case I'll have many pgPool services. Which would 'control' the
> primary/stand-by Postgres?

All of them. Again you should enable watchdog (but you should not
specify VIP this time), which is in charge of conducting all watchdog
each other: when one of pgpool detects that primary PostgreSQL goes
down, it handles the case using failover script. Other pgpool should
be notified by watchdog "one of you colleague is processing the
failover event, so do not start failover process yourself" etc.

One of the drawbacks of the configuration is, number of connections to
PostgreSQL is growing because all of pgpool instances need to connect
to PostgreSQL. For example, if num_init_children = 10 (max_pool = 1
just for simplicity) and there's 4 pgpool instances, each PostgreSQL
must accepts 10*4 = 40 connections, not 10.

> Thanks for any help...
> Felipe
> Sp/Brazil

Best regards,
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php

More information about the pgpool-general mailing list