Connection pool metrics are monitored
Why it matters
Connection pool exhaustion produces silent request failures — requests queue behind a saturated pool, timeout, and return errors — with no visibility into why. CWE-400 (uncontrolled resource consumption) applies when pool limits are reached without detection. Without pool metrics, the team discovers saturation only when users report errors, not proactively when the pool approaches its limit. ISO 25010 resource-utilisation requires that resource consumption is observable; connection pool health is a critical operational signal for scaling decisions and for diagnosing connection leaks introduced by code changes.
Severity rationale
Info because pool monitoring improves operational visibility and incident detection speed but does not prevent failures — unmonitored pools still function until they are exhausted.
Remediation
Add pool event listeners to log connection activity and expose pool metrics through the /api/health endpoint. For Prisma, use the built-in $metrics API.
// pg Pool — monitor pool events
pool.on('connect', () => {
console.debug(`[pool] +1 connection. total=${pool.totalCount} idle=${pool.idleCount}`)
})
pool.on('acquire', () => {
if (pool.waitingCount > 0) {
console.warn(`[pool] ${pool.waitingCount} requests waiting — consider increasing pool max`)
}
})
pool.on('error', (err) => {
console.error('[pool] Idle client error:', err)
})
// Expose in /api/health response:
// { pool: { total: pool.totalCount, idle: pool.idleCount, waiting: pool.waitingCount } }
// Prisma metrics (4.9+)
const m = await prisma.$metrics.json()
// m.gauges: pool_active_connections, pool_idle_connections, pool_wait_count
// Forward to Datadog/Prometheus/your metrics backend
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Database Design & Operations Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-400 — Uncontrolled Resource Consumption
- iso-25010:2011 · performance-efficiency.resource-utilization — Resource Utilisation
Taxons
History
- 2026-04-18·v1.0.0·Initial import from database-design-operations·automated