---
title: "Discussion on \"Postgres connection pooling: why your app runs out of connections under load\" | Hashnode"
description: "Discussion on \"Postgres connection pooling: why your app runs out of connections under load\". Every connection is a real process, and Postgres runs out of them faster than you'd think"
url: "https://hashnode.com/posts/postgres-connection-pooling-why-your-app-runs-out-of-connections-under-load/6ab27f79094f9bcfd63c8e1a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Postgres connection pooling: why your app runs out of connections under load](https://amitshuklabag.hashnode.dev/postgres-connection-pooling-why-your-app-runs-out-of-connections-under-load?utm_source=hashnode&utm_medium=feed)

Every connection is a real process, and Postgres runs out of them faster than you'd think

Sep 22 · 5 min read · amitshuklabag.hashnode.dev  
Updated Oct 10  
Read the article

-   [#postgres](https://hashnode.com/tag/postgres)
-   [#database](https://hashnode.com/tag/database)
-   [#backend](https://hashnode.com/tag/backend)
-   [#devops](https://hashnode.com/tag/devops)

## Written by

[Amit Shukla](https://hashnode.com/@amitshuklabag)

@amitshuklabag · India

  
[View profile](https://hashnode.com/@amitshuklabag)

Software Engineer · DevOps & Platform Engineering · Applied AI

I build and operate platforms, and I write about what actually breaks. Docker, Kubernetes, Linux, Node.js, and applied AI (RAG, agents, MCP). Weekly deep dives here. Daily tips on Instagram @amitshuklabag.

## Responses 2

Markdown supported · ⌘↵ to post

[Sep 22](https://hashnode.com/posts/postgres-connection-pooling-why-your-app-runs-out-of-connections-under-load/6ab27f79094f9bcfd63c8e1a/comment/6ab284eae69a4757cff9e530)

Good rundown, and the PgBouncer transaction-mode tradeoff is the part people usually skip over. One thing worth adding to the "ORMs that don't clean up" cause: even with an in-app pool in place, a request that opens a transaction and then does slow I/O before committing (an external API call, a retry loop, a queue publish) still holds a real Postgres backend the whole time, and PgBouncer in transaction mode can't reclaim it either since it's mid-transaction from its point of view. We rely on idle\_in\_transaction\_session\_timeout on the Postgres side to kill those automatically rather than trusting every code path to clean up on its own, and pg\_stat\_activity filtered on state = 'idle in transaction' is usually the fastest way to find which endpoint is actually the culprit before guessing at pool sizes.

[Amit Shukla](https://hashnode.com/@amitshuklabag)

[Oct 2](https://hashnode.com/posts/postgres-connection-pooling-why-your-app-runs-out-of-connections-under-load/6ab27f79094f9bcfd63c8e1a/comment/6ab284eae69a4757cff9e530#reply-6abfe116570249a66b3ae514)

Great addition, and a sneaky one, because the pool looks healthy while one slow endpoint holds a backend hostage. Agree on setting idle\_in\_transaction\_session\_timeout as the backstop. The real fix is usually moving the API call or queue publish outside the transaction, but the timeout catches the paths nobody remembers. Your pg\_stat\_activity query is the first thing I'd run too.
