[pgpool-general: 8501] Re: load balancing

Tatsuo Ishii ishii at sraoss.co.jp
Tue Nov 22 11:27:55 JST 2022


> Hi,
> 
> is possible to send the selected queries directly to specific slave node ?
> 
> For example, if we have a master and two slaves (slave01 and slave02)  I
> would like direct one SELECT to slave slave02.
> OR if we have a master and one slave (slave01)  I would like direct one
> SELECT to slave not to master and others select should be load balanced to
> master and slave.

If the SELECT can only be issued in a particular session, you can use
app_name_redirect_preference_list for the purpose.

Set following to pgppol.conf and restart or reload pgpool.

app_name_redirect_preference_list = 'foo:1'

Here, 'foo' is an application name you want to use. '1' means
PostgreSQL node number. We suppose that node 0 is primary and 1 is
slave.

Start psql with the application name 'foo' and connect to pgpool.

PGAPPNAME=foo psql test

Issue a read only SELECT query you want to send to PostgreSQL node 1.

SELECT 1;

The SELECT should be forwarded to node 1.

Note that all read only SELECTs in the session will be forwarded to
node 1. If you want to forward SELECT to other than node 1, you need to
disconnect to pgpool and connect again. For example if you want to forward a SELECT to node 2, you can set:

app_name_redirect_preference_list = 'foo:1,bar:2'

and start psql:

PGAPPNAME=bar psql test

See manual for mode details.

https://www.pgpool.net/docs/latest/en/html/runtime-config-load-balancing.html#RUNTIME-CONFIG-LOAD-BALANCING-SETTINGS

Best reagards,
--
Tatsuo Ishii
SRA OSS LLC
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp



More information about the pgpool-general mailing list