PGPool II + Django w/ psycopg2 load balancing

681 Views Asked by At

I've a pool of applications running django 1.6 with psycopg2 on top of a PGPool II with two backends PostgreSQL servers. But all queries (read and/or write) are going to master PostgreSQL even SELECT.

As we can see on PGPool II documentation, if we have read queries into transactions we need to hit some conditions to load balancing os send to master. I know that we have some points of the code that we have SELECT into a transaction but we also have simple SELECT queries which is going to master too.

I'm not sure if, and what, conditions we are hitting to send all queries to master.

Here the table with conditions for load balancing:

enter image description here

1

There are 1 best solutions below

0
On

Sending all the queries to master is really weird. I don't know which version you're using and weather if you use "stream" as "master_slave_sub_mode". Let me assume you're using version 4.0.0 and master_slave_sub_mode is "stream"

load_balance_mode = on
master_slave_sub_mode = 'stream'
replication_mode = off
replicate_select = off
white_function_list = ''
black_function_list = ''
black_query_pattern_list = ''
database_redirect_preference_list = ''
app_name_redirect_preference_list = ''
allow_sql_comments = off
disable_load_balance_on_write = 'transaction'

Could you check with this setting? And FYI, 3.7.x has some issues on load balancing. I recommend you to upgrade the version if you're using 3.7.x.