pgcat.toml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #
  2. # PgCat config example.
  3. #
  4. #
  5. # General pooler settings
  6. [general]
  7. # What IP to run on, 0.0.0.0 means accessible from everywhere.
  8. host = "0.0.0.0"
  9. # Port to run on, same as PgBouncer used in this example.
  10. port = 6432
  11. # Whether to enable prometheus exporter or not.
  12. enable_prometheus_exporter = true
  13. # Port at which prometheus exporter listens on.
  14. prometheus_exporter_port = 9930
  15. # How long to wait before aborting a server connection (ms).
  16. connect_timeout = 1000
  17. # How much time to give the health check query to return with a result (ms).
  18. healthcheck_timeout = 1000
  19. # How long to keep connection available for immediate re-use, without running a healthcheck query on it
  20. healthcheck_delay = 30000
  21. # How much time to give clients during shutdown before forcibly killing client connections (ms).
  22. shutdown_timeout = 5000
  23. # For how long to ban a server if it fails a health check (seconds).
  24. ban_time = 60 # Seconds
  25. # If we should log client connections
  26. log_client_connections = false
  27. # If we should log client disconnections
  28. log_client_disconnections = false
  29. # Reload config automatically if it changes.
  30. autoreload = 15000
  31. # TLS
  32. tls_certificate = ".circleci/server.cert"
  33. tls_private_key = ".circleci/server.key"
  34. # Credentials to access the virtual administrative database (pgbouncer or pgcat)
  35. # Connecting to that database allows running commands like `SHOW POOLS`, `SHOW DATABASES`, etc..
  36. admin_username = "admin_user"
  37. admin_password = "admin_pass"
  38. # pool
  39. # configs are structured as pool.<pool_name>
  40. # the pool_name is what clients use as database name when connecting
  41. # For the example below a client can connect using "postgres://sharding_user:sharding_user@pgcat_host:pgcat_port/sharded_db"
  42. [pools.sharded_db]
  43. # Pool mode (see PgBouncer docs for more).
  44. # session: one server connection per connected client
  45. # transaction: one server connection per client transaction
  46. pool_mode = "transaction"
  47. # If the client doesn't specify, route traffic to
  48. # this role by default.
  49. #
  50. # any: round-robin between primary and replicas,
  51. # replica: round-robin between replicas only without touching the primary,
  52. # primary: all queries go to the primary unless otherwise specified.
  53. default_role = "any"
  54. # Query parser. If enabled, we'll attempt to parse
  55. # every incoming query to determine if it's a read or a write.
  56. # If it's a read query, we'll direct it to a replica. Otherwise, if it's a write,
  57. # we'll direct it to the primary.
  58. query_parser_enabled = true
  59. # If the query parser is enabled and this setting is enabled, the primary will be part of the pool of databases used for
  60. # load balancing of read queries. Otherwise, the primary will only be used for write
  61. # queries. The primary can always be explicitely selected with our custom protocol.
  62. primary_reads_enabled = true
  63. # So what if you wanted to implement a different hashing function,
  64. # or you've already built one and you want this pooler to use it?
  65. #
  66. # Current options:
  67. #
  68. # pg_bigint_hash: PARTITION BY HASH (Postgres hashing function)
  69. # sha1: A hashing function based on SHA1
  70. #
  71. sharding_function = "pg_bigint_hash"
  72. # Credentials for users that may connect to this cluster
  73. [pools.sharded_db.users.0]
  74. username = "sharding_user"
  75. password = "sharding_user"
  76. # Maximum number of server connections that can be established for this user
  77. # The maximum number of connection from a single Pgcat process to any database in the cluster
  78. # is the sum of pool_size across all users.
  79. pool_size = 9
  80. statement_timeout = 0
  81. [pools.sharded_db.users.1]
  82. username = "other_user"
  83. password = "other_user"
  84. pool_size = 21
  85. statement_timeout = 30000
  86. # Shard 0
  87. [pools.sharded_db.shards.0]
  88. # [ host, port, role ]
  89. servers = [
  90. [ "127.0.0.1", 5432, "primary" ],
  91. [ "localhost", 5432, "replica" ]
  92. ]
  93. # Database name (e.g. "postgres")
  94. database = "shard0"
  95. [pools.sharded_db.shards.1]
  96. servers = [
  97. [ "127.0.0.1", 5432, "primary" ],
  98. [ "localhost", 5432, "replica" ],
  99. ]
  100. database = "shard1"
  101. [pools.sharded_db.shards.2]
  102. servers = [
  103. [ "127.0.0.1", 5432, "primary" ],
  104. [ "localhost", 5432, "replica" ],
  105. ]
  106. database = "shard2"
  107. [pools.simple_db]
  108. pool_mode = "session"
  109. default_role = "primary"
  110. query_parser_enabled = true
  111. primary_reads_enabled = true
  112. sharding_function = "pg_bigint_hash"
  113. [pools.simple_db.users.0]
  114. username = "simple_user"
  115. password = "simple_user"
  116. pool_size = 5
  117. statement_timeout = 30000
  118. [pools.simple_db.shards.0]
  119. servers = [
  120. [ "127.0.0.1", 5432, "primary" ],
  121. [ "localhost", 5432, "replica" ]
  122. ]
  123. database = "some_db"