October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

Stop Killing Your Database: How Connection Pooling Works

Connection pooling cuts repeated connection setup and manages database connections, but pool size and reuse mode must fit actual concurrency, capacity, and session behavior.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connection pooling lets an application reuse database connections instead of repeatedly opening and closing them. It reduces connection setup work and helps control how many connections reach the database—but it does not make slow queries faster or increase the database’s underlying capacity. The right design depends on concurrency, database limits, and whether your application’s session behavior allows connections to be safely reused.

What is database connection pooling?

Without a pool, an application may open a database connection for a unit of work and close it afterward. Opening connections repeatedly can consume CPU and memory and involve TLS handshaking and authentication. Keeping many connections open at once also consumes database resources. A pool maintains a managed set of connections so work can reuse them rather than paying that setup cost each time. Amazon Web Services describes connection pooling as reducing the overhead of opening and closing connections and keeping many connections open simultaneously.

Pooling has two common locations. An application-level pool runs with an application instance and reuses connections for that instance’s work. A shared proxy or pooler sits between clients and the database; it can reuse a smaller set of backend database connections across more client connections, a practice AWS calls connection multiplexing. These approaches solve related but distinct problems: an application pool manages reuse locally, while a shared intermediary can coordinate backend reuse across clients.

Why are too many database connections bad?

Each open connection consumes resources, and connection setup has a cost. If many application instances each maintain their own connections, the total can grow beyond what the database can use efficiently. When the backend connection limit is reached, new work may wait to borrow a connection; that waiting can increase query latency even if the queries themselves have not changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall

Pooling can reduce repeated setup and constrain the number of simultaneous backend connections. It cannot fix an inefficient query, create more database capacity, or guarantee lower latency when all available connections are busy. Treat it as resource management, not a substitute for query tuning or capacity planning.

How does pooling mode affect connection reuse?

The key question for shared pooling is when a backend connection becomes available to another client. The answer depends on the pool mode and on whether the client uses session behavior that must remain attached to one backend connection.

Session pooling

In PgBouncer’s session mode, a server connection remains assigned to a client for the duration of that client’s session. This preserves session-level continuity but offers less opportunity to share backend connections across clients than a mode that releases them more frequently. PgBouncer documents session, transaction, and statement pooling modes in its configuration reference.

Transaction pooling

In transaction mode, PgBouncer makes the server connection available to the pool when a transaction ends. Amazon RDS Proxy similarly says that it can reuse a connection after each transaction by default: all statements in a transaction use the same underlying connection, and the connection can be assigned to a different session when that transaction ends. This is the mechanism that allows many client connections to share fewer backend connections.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reuse at transaction boundaries is safe only when the client’s behavior permits it. If a proxy detects a request that makes reassignment impractical—or cannot determine that reassignment is safe—it can pin the client connection to a backend for the remainder of that session. Pinned clients reduce multiplexing, particularly when their application-side connections sit idle. Do not assume a driver, prepared statement, session variable, or other session feature is compatible with transaction pooling: check the documentation for the exact pooler, driver, and versions you deploy. AWS explains connection reuse and pinning for RDS Proxy.

Statement pooling

PgBouncer also documents statement mode. Its presence does not mean it is appropriate for every application. Choose a mode only after checking the pooler’s version-specific rules against the application’s transaction and session behavior.

How do I choose a database connection pool size?

There is no universal pool size. Work from the database’s permitted connection budget and the application’s observed concurrent demand, and leave capacity for other database clients and operational needs.

  1. Find the backend budget. Check the database’s permitted connection total and identify any configured limits in the application pools or shared proxy. Count every application instance and other client that may connect; a per-instance limit multiplied across instances can be much larger than it looks.
  2. Measure demand and waiting. Observe concurrent connections in use, application-side acquisition waits and timeouts, and connection borrow latency. A pool that is too small can make application work queue; one that is too large can push the database toward saturation.
  3. Set limits and timeouts deliberately. Configure maximum connections, idle-connection behavior, and how long a request may wait to borrow a connection. The appropriate values depend on your workload and database capacity, so validate them under representative concurrency rather than treating a copied number as a rule.
  4. Preserve headroom and retest. After changing a limit, watch whether waits, borrow latency, or database connection use rise during peak traffic. Revisit the settings when instance counts, workload, or database capacity change.

For RDS Proxy specifically, AWS defines MaxConnectionsPercent as a limit relative to the database’s max_connections; it does not pre-create the entire allowed number. AWS recommends at least 30% headroom above maximum recent monitored usage for this setting, in part because capacity may need to be redistributed across proxy nodes. That is AWS operating guidance for this RDS Proxy configuration, not a general pool-sizing formula. AWS also warns that reaching the configured maximum can increase overall query latency and DatabaseConnectionsBorrowLatency. See AWS’s RDS Proxy connection settings and guidance.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I monitor when a pool is under pressure?

Look at both sides of the pool: whether the database is near its connection limit and whether application work is waiting to acquire a connection. For RDS Proxy, AWS names DatabaseConnections, MaxDatabaseConnectionsAllowed, and DatabaseConnectionsBorrowLatency as relevant metrics. Pair those with application-side acquisition waits and timeouts. If a shared proxy is in use, check pinning as well: a high number of pinned or idle pinned clients can explain why backend reuse is lower than expected.

Interpret these signals together. High connection use with rising borrow latency points to backend saturation or a restrictive limit; application acquisition waits with spare backend capacity may instead point to a small application pool or another application-side bottleneck. Metrics help locate the queue, but they do not by themselves identify a slow query.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Should I use PgBouncer or an application connection pool?

Choose based on where you need reuse, how the application behaves, and who will operate the additional layer—not on a claim that one approach is always superior.

Choice Where it runs What it reuses Key operational question
Application-level pool Within each application instance Connections used by that instance Do the per-instance limits add up to a safe total across all instances?
Shared proxy or pooler Between application clients and the database A backend connection set across clients when transaction and session behavior allow it Do backend limits, waiting behavior, pinning, and service metrics match the workload?

Application pooling and a shared proxy can coexist. That can be useful, but observe their combined behavior: if an application pool holds proxy client connections idle while those clients are pinned to backend connections, the proxy has fewer backend connections available to multiplex. A managed proxy also adds a service layer with its own limits and metrics; AWS describes RDS Proxy as managing pooling infrastructure for supported database targets. Review supported targets and proxy behavior in the RDS Proxy documentation.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A published AWS Database Blog example describes accepting 5,000 client connections while opening a maximum of 200 connections to a test RDS PostgreSQL instance. Those are figures from that test configuration, not a recommended ratio or a general performance result; the available description does not establish enough methodology or results to draw a broader numerical conclusion. AWS Database Blog

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.