Skip to main content

design-a-database-connection-pool

Design a database connection pool from database capacity, workload concurrency, transaction duration, timeouts, fairness, failover, and observability. Use when services contend for limited database sessions.

Source facts

Repository
protosphinx/sphinxstack
Last source activity
July 29, 2026 at 13:55
Detected SKILL.md language
English
Stars
3
Forks
0

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

File Explorer
2 files

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
design-a-database-connection-pool
category
code
description
Design a database connection pool from database capacity, workload concurrency, transaction duration, timeouts, fairness, failover, and observability. Use when services contend for limited database sessions.
# design-a-database-connection-pool ## When to use - Use for application, proxy, worker, or multitenant database access. - Do not multiply a per-process maximum without fleet-wide capacity math. ## Preconditions - Measure database limits, instances, replicas, services, concurrency, query duration, transactions, and failover. ## Procedure 1. Allocate a fleet-wide connection budget with reserve for operations and recovery. 2. Size per workload from measured concurrency and service objectives. 3. Define acquire, connect, query, transaction, idle, and lifetime timeouts. 4. Reset session state and prevent leaked transactions or tenant context. 5. Add fairness, backpressure, cancellation, health, and failover handling. 6. Test peak load, slow query, failover, scale-out, leak, and recovery. ## Failure plan - Shed or queue bounded work before exhausting database control capacity. ## Worked example Autoscaling doubles instances, so the per-instance pool shrinks to preserve the database-wide budget. ## Done - A pool design report records capacity, allocation, timeouts, lifecycle, fairness, reset, failover, and telemetry - Fleet, scale, leak, slow-query, tenant-state, failover, reserve, and recovery tests verify safety
View on GitHub