Question

I have a Python/Django app that will require database load balancing at some point in the near future. In the meantime I'm trying to learn to implement pgpool on a local virtual machine setup.

I have 4 Ubuntu 12.04 VMs:

192.168.1.80 <- pool, pgppool2 installed and accessible
192.168.1.81 <- db1 master
192.168.1.82 <- db2 slave
192.168.1.83 <- db3 slave

I have pgpool-II version 3.1.1 and my database servers are running PostgreSQL 9.1.

I have my app's db connection pointed to 192.168.1.80:9999 and it works fine.

The problem is when I use Apache ab to throw some load at it, none of SELECT queries appear to be balanced. All the load goes to my db1 master. Also, quite concerning is the load on the pool server itself, it is really high compared to db1, maybe an average of 8-10 times higher. Meanwhile my db2 and db3 servers have a load of nearly zero, they appear to only be replicating from db1, which isn't very load intensive for my tests with ab.

ab -n 300 -c 4 -C 'sessionid=80a5fd3b6bb59051515e734326735f80' http://192.168.1.17:8000/contacts/

That drives the load on my pool server up to about 2.3. Load on db1 is about 0.4 and load on db2 and db3 is nearly zero.

Can someone take a look at my config and see if what I'm doing wrong?

backend_hostname0 = '192.168.1.81'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = '/var/lib/postgresql/9.1/main'
backend_flag0 = 'ALLOW_TO_FAILOVER'

backend_hostname1 = '192.168.1.82'
backend_port1 = 5433
backend_weight1 = 1
backend_data_directory1 = '/var/lib/postgresql/9.1/main'
backend_flag1 = 'ALLOW_TO_FAILOVER'

backend_hostname2 = '192.168.1.83'
backend_port2 = 5434
backend_weight2 = 1
backend_data_directory2 = '/var/lib/postgresql/9.1/main'
backend_flag2 = 'ALLOW_TO_FAILOVER'

load_balance_mode = on

My entire config is here:

http://pastebin.com/raw.php?i=wzBc0aSp
Was it helpful?

Solution

I needed

replication_mode = off
master_slave_mode = on

Thanks to Tatsuo Ishii:

http://www.pgpool.net/pipermail/pgpool-general/2013-January/001309.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top