Home
%3CLINGO-SUB%20id%3D%22lingo-sub-825717%22%20slang%3D%22en-US%22%3ENot%20all%20Postgres%20connection%20pooling%20is%20equal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-825717%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ENot%20a%20week%20goes%20by%20that%20I%20don't%20have%20a%20conversation%20about%20connection%20management%20in%20Postgres.%20Connection%20management%20itself%20is%20admittedly%20a%20sore%20spot%20for%20Postgres%2C%20but%20it%20is%20also%20a%20confusing%20one%20for%20many.%20The%20cost%20of%20connections%20in%20Postgres%20has%20been%20talked%20about%20a%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-for-PostgreSQL%2FConnection-handling-best-practice-with-PostgreSQL%2Fba-p%2F790883%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Efew%20times%20before%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20The%20short%20summary%20is%20that%20each%20connection%20into%20Postgres%20is%20going%20to%20consume%20about%2010%20MB%20of%20memory%20from%20your%20database.%20If%20you%20have%2050%20connections%2C%20you're%20using%20about%20500%20MB%20of%20memory%20on%20just%20having%20those%20connections.%20The%20wasted%20memory%20is%20one%20thing%2C%20but%20the%20other%20is%20that%20even%20when%20a%20connection%20isn't%20doing%20anything%20there%20is%20some%20additional%20overhead%20for%20Postgres%20itself.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAnother%20detail%20of%20connections%2C%20especially%20within%20the%20cloud%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bis%20security.%20You%20want%20your%20database%20secured%2C%20and%20when%20you%20connect%20with%20SSL%20required%20there%20is%20a%20negotiation%20time%20that%20takes%20place%20on%20each%20connection.%20This%20can%20bring%20the%20cost%20of%20connecting%20to%20a%20database%20up%20to%2010s%20or%20even%20100s%20of%20milliseconds.%20When%20your%20application%20has%20many%20short%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E-%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Elived%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Erequests%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthis%20adds%20a%20lot%20of%20overhead.%20You%20could%20easily%20spend%2080%20milliseconds%20to%20establish%20a%20connection%2C%20only%20for%20your%20query%20to%20execute%20in%203%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ems%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20and%20then%20the%20total%20response%20time%20to%20the%20customer%20complete%20in%20under%20100ms.%20Yet%2C%20most%20of%20your%20time%20was%20wasted%20on%20simply%20connecting%20to%20the%20DB.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20common%20recommendation%20to%20fix%20this%20is%20connection%20pooling.%20A%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FConnection_pool%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Econnection%20pool%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bis%20a%20cache%20of%20connections%20that%20get%20reused%20when%20future%20requests%20are%20made.%20What%20this%20means%20is%20if%20a%20new%20request%20comes%20in%20the%20application%20server%20will%20already%20have%20a%20connection%20sitting%20there%20available.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20approach%20you%20take%20to%20connection%20pooling%20will%20significantly%20impact%20how%20healthy%20your%20database%20is%20over%20the%20long%20term.%20Most%20take%20the%20quick%20approach%20of%20putting%20in%20place%20connection%20pooling%20using%20your%20given%20application%20framework.%20For%20example%20with%20Ruby%20on%20Rails%20you%20can%20set%20your%20connection%20pool%20by%20simply%20setting%20a%20%60config%5B'pool%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E'%5D%60%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bto%20some%20value.%20This%20means%20for%20each%20running%20rails%20server%20you'll%20have%20a%20set%20pool.%20When%20a%20new%20request%20comes%20in%20it%20will%20take%20that%20connection%20and%20give%20it%20to%20the%20running%20web%20process%2C%20when%20it's%20done%20it%20will%20return%20it%20back%20to%20the%20pool.%20There%20is%20no%20expensive%20connection%20time.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ELet%E2%80%99s%20look%20at%20an%20example.%20Below%20we%20have%20a%20simplified%20architecture%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%20In%20the%20below%20you%20can%20see%20we%20have%204%20rails%20web%20servers%20running%2C%20each%20has%20a%20connection%20pool%20of%205%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128837iED5AAAD1412CF755%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eissue%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehere%20is%20that%20you%20have%20a%20lot%20of%20connections%20open%20and%20consuming%20database%20resources%20without%20ever%20being%20used.%20As%20you%20can%20see%20in%20our%20example%20above%20out%20of%2020%20%22total%20connections%22%20only%206%20are%20being%20used.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ELeaving%2014%20idle%20connections%2C%20t%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehis%20means%20we're%20wasting%2014%20*%2010%20MB%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bor%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Broughly%20140MB%20of%20resources.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EEnter%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Epgbouncer%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EPgbouncer%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bis%20a%20connection%20pooler%20that%20sits%20between%20your%20application%20and%20the%20database.%20When%20it%20needs%20a%20new%20connection%20to%20the%20database%20it%20grabs%20it%2C%20and%20then%20continues%20to%20re-use%20it%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EA%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efter%20a%20certain%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eperiod%20of%20time%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bit%20releases%20that%20connection.%20What%20this%20means%20is%20when%20your%20application%20grabs%20a%20connection%20to%20the%20database%20and%20doesn%E2%80%99t%20use%20it%2C%20it%E2%80%99s%20not%20actually%20passed%20on%20and%20consumed%20as%20an%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bidle%20connection.%20You%20can%20see%20how%20this%20changes%20what%20your%20database%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eactually%20sees%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bbelow.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128838iF01789B120795C29%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_1.png%22%20title%3D%22clipboard_image_1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMany%20databases%20can%20benefit%20from%20connection%20pooling%20with%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Epgbouncer%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Beven%20if%20they%20already%20have%20connection%20pooling%20setup%20at%20their%20application%20level.%20This%20can%20begin%20as%20early%20as%2010s%20of%20connections%20to%20your%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edatabase%2C%20and%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bis%20critical%20when%20you%20have%20several%20hundred%20connections.%20You%20can%20get%20a%20better%20idea%20of%20how%20many%20active%20vs.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ei%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edle%20connections%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Byou%20have%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bby%20executing%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-for-PostgreSQL%2FConnection-handling-best-practice-with-PostgreSQL%2Fba-p%2F790883%22%20target%3D%22_self%22%3Equery%20high%3C%2FA%3E%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-for-PostgreSQL%2FConnection-handling-best-practice-with-PostgreSQL%2Fba-p%2F790883%22%20target%3D%22_self%22%3Elighted%20in%20this%20post%3C%2FA%3E.%20And%20if%20you%E2%80%99re%20looking%20to%20get%20started%20and%20setup%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Epgbouncer%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20here%20are%20some%20quick%20and%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Database-for-PostgreSQL%2FSteps-to-install-and-setup-PgBouncer-connection-pooling-proxy%2Fba-p%2F730555%22%20target%3D%22_self%22%3Esimple%20steps%20for%20you%3C%2FA%3E.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EOne%20final%20note%2C%20w%3C%2FSPAN%3E%3C%2FI%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehile%20this%20is%20a%20limitation%20of%20Postgres%20today%2C%20this%20doesn't%20mean%20it%20will%20remain%20this%20way%20forever.%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-825717%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20are%20different%20forms%20of%20connection%20pooling%20that%20have%20varying%20levels%20of%20impact%20when%20it%20comes%20to%20your%20database%2C%20learn%20a%20bit%20more%20on%20what%20each%20means.%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Microsoft

Not a week goes by that I don't have a conversation about connection management in Postgres. Connection management itself is admittedly a sore spot for Postgres, but it is also a confusing one for many. The cost of connections in Postgres has been talked about a few times before. The short summary is that each connection into Postgres is going to consume about 10 MB of memory from your database. If you have 50 connections, you're using about 500 MB of memory on just having those connections. The wasted memory is one thing, but the other is that even when a connection isn't doing anything there is some additional overhead for Postgres itself. 

  

Another detail of connections, especially within the cloud, is security. You want your database secured, and when you connect with SSL required there is a negotiation time that takes place on each connection. This can bring the cost of connecting to a database up to 10s or even 100s of milliseconds. When your application has many short-lived requests this adds a lot of overhead. You could easily spend 80 milliseconds to establish a connection, only for your query to execute in 3 ms, and then the total response time to the customer complete in under 100ms. Yet, most of your time was wasted on simply connecting to the DB. 

  

The common recommendation to fix this is connection pooling. A connection pool is a cache of connections that get reused when future requests are made. What this means is if a new request comes in the application server will already have a connection sitting there available.  

  

The approach you take to connection pooling will significantly impact how healthy your database is over the long term. Most take the quick approach of putting in place connection pooling using your given application framework. For example with Ruby on Rails you can set your connection pool by simply setting a `config['pool']` to some value. This means for each running rails server you'll have a set pool. When a new request comes in it will take that connection and give it to the running web process, when it's done it will return it back to the pool. There is no expensive connection time. 

 

Let’s look at an example. Below we have a simplified architecture. In the below you can see we have 4 rails web servers running, each has a connection pool of 5 

 

clipboard_image_0.png

 

 

The issue here is that you have a lot of connections open and consuming database resources without ever being used. As you can see in our example above out of 20 "total connections" only 6 are being used. Leaving 14 idle connections, this means we're wasting 14 * 10 MB or roughly 140MB of resources. 

 

Enter pgbouncerPgbouncer is a connection pooler that sits between your application and the database. When it needs a new connection to the database it grabs it, and then continues to re-use it. After a certain period of time it releases that connection. What this means is when your application grabs a connection to the database and doesn’t use it, it’s not actually passed on and consumed as an idle connection. You can see how this changes what your database actually sees below. 

 

clipboard_image_1.png

 

  

  

Many databases can benefit from connection pooling with pgbouncer even if they already have connection pooling setup at their application level. This can begin as early as 10s of connections to your database, and is critical when you have several hundred connections. You can get a better idea of how many active vs. idle connections you have by executing the query highlighted in this post. And if you’re looking to get started and setup pgbouncer, here are some quick and simple steps for you. 

 

One final note, while this is a limitation of Postgres today, this doesn't mean it will remain this way forever.