Skip to content

Instantly share code, notes, and snippets.

@alazycoder101
Created October 23, 2021 09:05
Show Gist options
  • Save alazycoder101/1ff20b29fe5a52752bba040f49ede2f4 to your computer and use it in GitHub Desktop.
Save alazycoder101/1ff20b29fe5a52752bba040f49ede2f4 to your computer and use it in GitHub Desktop.
pgpool configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: pgpool-config
labels:
name: pgpool-config
data:
pgpool.conf: |-
listen_addresses = '*'
port = 9999
socket_dir = '/var/run/pgpool'
pcp_listen_addresses = '*'
pcp_port = 9898
pcp_socket_dir = '/var/run/pgpool'
backend_hostname0 = 'postgres.db'
backend_port0 = 5432
backend_weight0 = 1
backend_flag0 = 'ALWAYS_PRIMARY|DISALLOW_TO_FAILOVER'
backend_hostname1 = 'postgres-replica.db'
backend_port1 = 5432
backend_weight1 = 1
backend_flag1 = 'DISALLOW_TO_FAILOVER'
sr_check_period = 0
enable_pool_hba = false
allow_clear_text_frontend_auth = on
backend_clustering_mode = 'streaming_replication'
# pool_instances*max_pool*num_init_children*2 <= (max_connections - superuser_reserved_connections) (query canceling needed)
max_pool = 2 # number of distinct combinations of users, databases and connection options for the application connections
num_init_children = 50
# max_client_connection = num_init_children*listen_backlog_multiplier
listen_backlog_multiplier = 2
# set to 1: refuse the incoming client connections with error message "Sorry, too many clients already" rather than block it when client connections > "num_init_children - reserved_connections".
reserved_connections = 0
# idle 5 mins
child_life_time = 300
# serve 300 connection then terminate
child_max_connections = 300
# idle 5 mins to backend
connection_life_time = 300
client_idle_limit = 0
connection_cache = on
load_balance_mode = on
ssl = off
failover_on_backend_error = off
# read from primary after writing until session over
disable_load_balance_on_write = always
# log
log_line_prefix = '%t: pid %p: db %d: '
log_connections = on
log_hostname = off
log_statement = off
log_per_node_statement = off
log_standby_delay = 'if_over_threshold'
# debug
log_error_verbosity = default
client_min_messages = log
pool_hba.conf: |-
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host sameuser all 10.171.0.0/17 md5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment