{"id":513,"date":"2026-03-03T05:15:05","date_gmt":"2026-03-03T05:15:05","guid":{"rendered":"http:\/\/77interactive.com\/?p=513"},"modified":"2026-03-04T17:01:56","modified_gmt":"2026-03-04T17:01:56","slug":"pgbouncer","status":"publish","type":"post","link":"http:\/\/77interactive.com\/?p=513","title":{"rendered":"pgbouncer"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Download<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/repo.percona.com\/apt\/percona-release_latest.generic_all.deb\nsudo dpkg -i percona-release_latest.generic_all.deb\nsudo percona-release setup ppg-18\nsudo apt install percona-pgbouncer -y<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">pgbouncer user<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>-- This file sets up the database role and function for PgBouncer authentication.\nCREATE ROLE pgbouncer_auth WITH LOGIN PASSWORD 'REPLACE_ME_LONG_RANDOM5432';\n\n-- Execute the following so the pgbouncer_auth role can access the get_auth function and schema.\nGRANT USAGE ON SCHEMA pgbouncer TO pgbouncer_auth;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Get Auth<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>-- This file sets up the database role and function for PgBouncer authentication.\nCREATE SCHEMA IF NOT EXISTS pgbouncer;\nGRANT USAGE ON SCHEMA pgbouncer TO pgbouncer_auth;\n\n-- Create the get_auth function that PgBouncer will call to retrieve user credentials.\nCREATE OR REPLACE FUNCTION pgbouncer.get_auth(p_usename text)\nRETURNS TABLE(username text, password text)\nLANGUAGE sql\nSECURITY DEFINER\nAS $$\n  SELECT rolname::text, rolpassword::text\n  FROM pg_authid\n  WHERE rolname = p_usename;\n$$;\n\n-- Execute the following so the pgbouncer_auth role can access the get_auth function and schema.\nREVOKE ALL ON FUNCTION pgbouncer.get_auth(text) FROM PUBLIC;\nGRANT EXECUTE ON FUNCTION pgbouncer.get_auth(text) TO pgbouncer_auth;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Min pgbouncer.ini<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;databases]\naws_dbz_001 = host=172.31.11.248 port=5432 dbname=example auth_user=pgbouncer_auth\naws_dbz_001_ro = host=172.31.9.92 port=5432 dbname=example auth_user=pgbouncer_auth\naws_dbz_sales = host=172.31.11.248 port=5432 dbname=sales auth_user=pgbouncer_auth\naws_dbz_sales_ro = host=172.31.9.92 port=5432 dbname=sales auth_user=pgbouncer_auth\n\n\n&#91;pgbouncer]\nlisten_addr = 0.0.0.0\nlisten_port = 6432\n\nauth_type = scram-sha-256\nauth_user = pgbouncer_auth\nauth_query = SELECT username, password FROM pgbouncer.get_auth($1)\nauth_file  = \/etc\/pgbouncer\/userlist.txt \n\n; Use session pooling for long-running reports\n; Use transaction pooling for short transactions (e.g. BI tools)\npool_mode = transaction\n\nmax_client_conn = 200\n\n; Cap true DB concurrency for reporting\ndefault_pool_size = 25\nreserve_pool_size = 10\nreserve_pool_timeout = 5\n\nlogfile = \/var\/log\/postgresql\/pgbouncer.log\npidfile = \/var\/run\/postgresql\/pgbouncer.pid<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Max pgbouncer<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;databases]\naurora_reader = host=&lt;aurora-reader-endpoint> port=5432 dbname=&lt;db> auth_user=pgbouncer_auth\n\n&#91;pgbouncer]\nlisten_addr = 0.0.0.0\nlisten_port = 6432\n\nauth_type = scram-sha-256\nauth_file = \/etc\/pgbouncer\/userlist.txt\n\n; Use session pooling for long-running reports\npool_mode = session\n\nmax_client_conn = 2000\n\n; Cap true DB concurrency for reporting\ndefault_pool_size = 25\nreserve_pool_size = 10\nreserve_pool_timeout = 5\n\n; Don\u2019t kill long queries\nquery_timeout = 0\n\n; Let users queue (tune to expectations)\nquery_wait_timeout = 1800   ; 30 minutes\n\n; Keep BI tool connections stable\nclient_idle_timeout = 3600  ; 60 minutes\n\n; Backend hygiene\nserver_idle_timeout = 600\nserver_lifetime = 3600      ; recycle backend conns hourly\nserver_connect_timeout = 15\nserver_login_retry = 15\n\n; Logging\nlog_connections = 1\nlog_disconnections = 1\nstats_period = 60<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Download pgbouncer user Get Auth Min pgbouncer.ini Max pgbouncer<\/p>\n","protected":false},"author":1,"featured_media":514,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[59,17,18],"class_list":["post-513","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql","tag-pgbouncer","tag-postgres","tag-postgresql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>pgbouncer - 77 Interactive<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/77interactive.com\/?p=513\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"pgbouncer - 77 Interactive\" \/>\n<meta property=\"og:description\" content=\"Download pgbouncer user Get Auth Min pgbouncer.ini Max pgbouncer\" \/>\n<meta property=\"og:url\" content=\"http:\/\/77interactive.com\/?p=513\" \/>\n<meta property=\"og:site_name\" content=\"77 Interactive\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-03T05:15:05+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-04T17:01:56+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"1024\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rudy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rudy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/77interactive.com\/?p=513#article\",\"isPartOf\":{\"@id\":\"http:\/\/77interactive.com\/?p=513\"},\"author\":{\"name\":\"Rudy\",\"@id\":\"http:\/\/77interactive.com\/#\/schema\/person\/0e61d2a984b8304618026b207e6121e9\"},\"headline\":\"pgbouncer\",\"datePublished\":\"2026-03-03T05:15:05+00:00\",\"dateModified\":\"2026-03-04T17:01:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/77interactive.com\/?p=513\"},\"wordCount\":11,\"image\":{\"@id\":\"http:\/\/77interactive.com\/?p=513#primaryimage\"},\"thumbnailUrl\":\"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png\",\"keywords\":[\"pgbouncer\",\"postgres\",\"postgresql\"],\"articleSection\":[\"PostgreSQL\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/77interactive.com\/?p=513\",\"url\":\"http:\/\/77interactive.com\/?p=513\",\"name\":\"pgbouncer - 77 Interactive\",\"isPartOf\":{\"@id\":\"http:\/\/77interactive.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/77interactive.com\/?p=513#primaryimage\"},\"image\":{\"@id\":\"http:\/\/77interactive.com\/?p=513#primaryimage\"},\"thumbnailUrl\":\"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png\",\"datePublished\":\"2026-03-03T05:15:05+00:00\",\"dateModified\":\"2026-03-04T17:01:56+00:00\",\"author\":{\"@id\":\"http:\/\/77interactive.com\/#\/schema\/person\/0e61d2a984b8304618026b207e6121e9\"},\"breadcrumb\":{\"@id\":\"http:\/\/77interactive.com\/?p=513#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/77interactive.com\/?p=513\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/77interactive.com\/?p=513#primaryimage\",\"url\":\"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png\",\"contentUrl\":\"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png\",\"width\":1024,\"height\":1024,\"caption\":\"pgbouncer\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/77interactive.com\/?p=513#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/77interactive.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"pgbouncer\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/77interactive.com\/#website\",\"url\":\"http:\/\/77interactive.com\/\",\"name\":\"77 Interactive\",\"description\":\"Rudy&#039;s Code snippets\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/77interactive.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/77interactive.com\/#\/schema\/person\/0e61d2a984b8304618026b207e6121e9\",\"name\":\"Rudy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/77interactive.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e336b9aecd39b40691ff8ccfcd68506415072dbe8caffc0485b94a1bc22b774d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e336b9aecd39b40691ff8ccfcd68506415072dbe8caffc0485b94a1bc22b774d?s=96&d=mm&r=g\",\"caption\":\"Rudy\"},\"url\":\"http:\/\/77interactive.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"pgbouncer - 77 Interactive","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/77interactive.com\/?p=513","og_locale":"en_US","og_type":"article","og_title":"pgbouncer - 77 Interactive","og_description":"Download pgbouncer user Get Auth Min pgbouncer.ini Max pgbouncer","og_url":"http:\/\/77interactive.com\/?p=513","og_site_name":"77 Interactive","article_published_time":"2026-03-03T05:15:05+00:00","article_modified_time":"2026-03-04T17:01:56+00:00","og_image":[{"width":1024,"height":1024,"url":"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png","type":"image\/png"}],"author":"Rudy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rudy","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/77interactive.com\/?p=513#article","isPartOf":{"@id":"http:\/\/77interactive.com\/?p=513"},"author":{"name":"Rudy","@id":"http:\/\/77interactive.com\/#\/schema\/person\/0e61d2a984b8304618026b207e6121e9"},"headline":"pgbouncer","datePublished":"2026-03-03T05:15:05+00:00","dateModified":"2026-03-04T17:01:56+00:00","mainEntityOfPage":{"@id":"http:\/\/77interactive.com\/?p=513"},"wordCount":11,"image":{"@id":"http:\/\/77interactive.com\/?p=513#primaryimage"},"thumbnailUrl":"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png","keywords":["pgbouncer","postgres","postgresql"],"articleSection":["PostgreSQL"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/77interactive.com\/?p=513","url":"http:\/\/77interactive.com\/?p=513","name":"pgbouncer - 77 Interactive","isPartOf":{"@id":"http:\/\/77interactive.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/77interactive.com\/?p=513#primaryimage"},"image":{"@id":"http:\/\/77interactive.com\/?p=513#primaryimage"},"thumbnailUrl":"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png","datePublished":"2026-03-03T05:15:05+00:00","dateModified":"2026-03-04T17:01:56+00:00","author":{"@id":"http:\/\/77interactive.com\/#\/schema\/person\/0e61d2a984b8304618026b207e6121e9"},"breadcrumb":{"@id":"http:\/\/77interactive.com\/?p=513#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/77interactive.com\/?p=513"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/77interactive.com\/?p=513#primaryimage","url":"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png","contentUrl":"http:\/\/77interactive.com\/wp-content\/uploads\/2026\/03\/Copilot_20260302_231425.png","width":1024,"height":1024,"caption":"pgbouncer"},{"@type":"BreadcrumbList","@id":"http:\/\/77interactive.com\/?p=513#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/77interactive.com\/"},{"@type":"ListItem","position":2,"name":"pgbouncer"}]},{"@type":"WebSite","@id":"http:\/\/77interactive.com\/#website","url":"http:\/\/77interactive.com\/","name":"77 Interactive","description":"Rudy&#039;s Code snippets","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/77interactive.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/77interactive.com\/#\/schema\/person\/0e61d2a984b8304618026b207e6121e9","name":"Rudy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/77interactive.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e336b9aecd39b40691ff8ccfcd68506415072dbe8caffc0485b94a1bc22b774d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e336b9aecd39b40691ff8ccfcd68506415072dbe8caffc0485b94a1bc22b774d?s=96&d=mm&r=g","caption":"Rudy"},"url":"http:\/\/77interactive.com\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/posts\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/77interactive.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=513"}],"version-history":[{"count":1,"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":515,"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions\/515"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/77interactive.com\/index.php?rest_route=\/wp\/v2\/media\/514"}],"wp:attachment":[{"href":"http:\/\/77interactive.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/77interactive.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/77interactive.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}