1.3. 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.

    $ pgbench -p 11000 -c 10 -S -T 10 test
    starting vacuum...end.
    transaction type: <builtin: select only>
    scaling factor: 1
    query mode: simple
    number of clients: 10
    number of threads: 1
    duration: 10 s
    number of transactions actually processed: 148044
    latency average = 0.676 ms
    tps = 14802.897506 (including connections establishing)
    tps = 14810.213749 (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 
    ---------+----------+-------+--------+-----------+---------+------------+-------------------+-------------------
    0       | /tmp     | 11002 | up     | 0.500000  | primary | 75152      | true              | 0
    1       | /tmp     | 11003 | up     | 0.500000  | standby | 72893      | false             | 0
    (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.7 for more details.