1.4. Testing Load Balance

Pgpool-II allows read query load balancing. It is enabled by default. To see the effect, let's use pgbench -S command.

    $ ./shutdownall
    $ ./startall
    $ pgbench -p 11000 -c 10 -j 10 -S -T 60 test
    starting vacuum...end.
    transaction type: <builtin: select only>
    scaling factor: 1
    query mode: simple
    number of clients: 10
    number of threads: 10
    duration: 60 s
    number of transactions actually processed: 1086766
    latency average = 0.552 ms
    tps = 18112.487043 (including connections establishing)
    tps = 18125.572952 (excluding connections establishing)

    $ psql -p 11000 -c "show pool_nodes" test
    node_id | hostname | port  | status | lb_weight |  role   | select_cnt | load_balance_node | replication_delay | last_status_change
    ---------+----------+-------+--------+-----------+---------+------------+-------------------+-------------------+---------------------
    0       | /tmp     | 11002 | up     | 0.500000  | primary | 537644     | false             | 0                 | 2019-01-31 11:51:58
    1       | /tmp     | 11003 | up     | 0.500000  | standby | 548582     | true              | 0                 | 2019-01-31 11:51:58
    (2 rows)
   

"select_cnt" column shows how many SELECT are dispatched to each node. Since with the default configuration, Pgpool-II tries to dispatch equal number of SELECT, the column shows almost same numbers.

Pgpool-II offers more sophisticated strategy for load balancing. See Section 5.8 for more details.