Skip to content
BENIBIX Learn

Connection Pool

Development🗃️ DatabasesDatabases in Code

Also known as Database Connection Pool, Connection Pooling

Open links to a database that an app keeps ready. It uses them again.

Think of it like

Think of it like a row of shared bikes. You take one, ride, and put it back for the next person.

Example

Lucy's app opened a new connection for each request and fell over at 100 users. A pool of 20 shared connections fixed it.

Why it matters

Pools make each request fast. They also stop the database from drowning in links.

Definition

A connection pool is a set of open links to a database that an app keeps ready. Opening a new one is slow, because both sides must shake hands and check passwords. With a pool, each request borrows a link and hands it back when it is done. It also caps how many links hit the database at once. PostgreSQL allows 100 by default, so the cap matters.

Common mistake

Making the pool far too big. A database with too many connections at once gets slower, not faster.

Key takeaways

  1. 1
    Open once, reuse. No handshake each time.
  2. 2
    Borrow and return. Each request hands it back.
  3. 3
    A cap. Limits the load on the database.