|
| 1 | +# |
| 2 | +# PgCat config example. |
| 3 | +# |
| 4 | + |
| 5 | +# |
| 6 | +# General pooler settings |
| 7 | +[general] |
| 8 | + |
| 9 | +# What IP to run on, 0.0.0.0 means accessible from everywhere. |
| 10 | +host = "0.0.0.0" |
| 11 | + |
| 12 | +# Port to run on, same as PgBouncer used in this example. |
| 13 | +port = 6432 |
| 14 | + |
| 15 | +# How many connections to allocate per server. |
| 16 | +pool_size = 15 |
| 17 | + |
| 18 | +# Pool mode (see PgBouncer docs for more). |
| 19 | +# session: one server connection per connected client |
| 20 | +# transaction: one server connection per client transaction |
| 21 | +pool_mode = "transaction" |
| 22 | + |
| 23 | +# How long to wait before aborting a server connection (ms). |
| 24 | +connect_timeout = 100 |
| 25 | + |
| 26 | +# How much time to give `SELECT 1` health check query to return with a result (ms). |
| 27 | +healthcheck_timeout = 100 |
| 28 | + |
| 29 | +# For how long to ban a server if it fails a health check (seconds). |
| 30 | +ban_time = 60 # Seconds |
| 31 | + |
| 32 | +# Stats will be sent here |
| 33 | +statsd_address = "127.0.0.1:8125" |
| 34 | + |
| 35 | +# |
| 36 | +# User to use for authentication against the server. |
| 37 | +[user] |
| 38 | +name = "sharding_user" |
| 39 | +password = "sharding_user" |
| 40 | + |
| 41 | + |
| 42 | +# |
| 43 | +# Shards in the cluster |
| 44 | +[shards] |
| 45 | + |
| 46 | +# Shard 0 |
| 47 | +[shards.0] |
| 48 | + |
| 49 | +# [ host, port, role ] |
| 50 | +servers = [ |
| 51 | + [ "127.0.0.1", 5432, "primary" ], |
| 52 | + [ "localhost", 5433, "replica" ], |
| 53 | + # [ "127.0.1.1", 5432, "replica" ], |
| 54 | +] |
| 55 | +# Database name (e.g. "postgres") |
| 56 | +database = "shard0" |
| 57 | + |
| 58 | +[shards.1] |
| 59 | +# [ host, port, role ] |
| 60 | +servers = [ |
| 61 | + [ "127.0.0.1", 5432, "primary" ], |
| 62 | + [ "localhost", 5433, "replica" ], |
| 63 | + # [ "127.0.1.1", 5432, "replica" ], |
| 64 | +] |
| 65 | +database = "shard1" |
| 66 | + |
| 67 | +[shards.2] |
| 68 | +# [ host, port, role ] |
| 69 | +servers = [ |
| 70 | + [ "127.0.0.1", 5432, "primary" ], |
| 71 | + [ "localhost", 5433, "replica" ], |
| 72 | + # [ "127.0.1.1", 5432, "replica" ], |
| 73 | +] |
| 74 | +database = "shard2" |
| 75 | + |
| 76 | + |
| 77 | +# Settings for our query routing layer. |
| 78 | +[query_router] |
| 79 | + |
| 80 | +# If the client doesn't specify, route traffic to |
| 81 | +# this role by default. |
| 82 | +# |
| 83 | +# any: round-robin between primary and replicas, |
| 84 | +# replica: round-robin between replicas only without touching the primary, |
| 85 | +# primary: all queries go to the primary unless otherwise specified. |
| 86 | +default_role = "any" |
| 87 | + |
| 88 | + |
| 89 | +# Query parser. If enabled, we'll attempt to parse |
| 90 | +# every incoming query to determine if it's a read or a write. |
| 91 | +# If it's a read query, we'll direct it to a replica. Otherwise, if it's a write, |
| 92 | +# we'll direct it to the primary. |
| 93 | +query_parser_enabled = false |
| 94 | + |
| 95 | +# If the query parser is enabled and this setting is enabled, the primary will be part of the pool of databases used for |
| 96 | +# load balancing of read queries. Otherwise, the primary will only be used for write |
| 97 | +# queries. The primary can always be explicitely selected with our custom protocol. |
| 98 | +primary_reads_enabled = true |
| 99 | + |
| 100 | +# So what if you wanted to implement a different hashing function, |
| 101 | +# or you've already built one and you want this pooler to use it? |
| 102 | +# |
| 103 | +# Current options: |
| 104 | +# |
| 105 | +# pg_bigint_hash: PARTITION BY HASH (Postgres hashing function) |
| 106 | +# sha1: A hashing function based on SHA1 |
| 107 | +# |
| 108 | +sharding_function = "pg_bigint_hash" |
0 commit comments