skills/database-connection-pool-manager/SKILL.md
PgBouncer, connection optimization, and pooling strategies for database performance. Activate on: connection pool, PgBouncer, database connections, pool size, connection limit, Prisma pool, Drizzle pool. NOT for: query optimization (use data-warehouse-optimizer), database schema design (use dimensional-modeler).
npx skillsauth add curiositech/windags-skills database-connection-pool-managerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Optimize database connection pools for throughput, latency, and resource efficiency using PgBouncer, application-level poolers, and cloud-managed pools.
Activate on: "connection pool", "PgBouncer", "database connections", "pool size", "connection limit", "too many connections", "connection timeout", "Prisma pool", "Supabase pooler"
NOT for: SQL query optimization → data-warehouse-optimizer | Schema design → dimensional-modeler | ORM selection → api-architect
SELECT count(*) FROM pg_stat_activity to understand baselineconnections = (cores * 2) + spindle_count per PostgreSQL docs| Domain | Technologies | |--------|-------------| | External Poolers | PgBouncer 1.23+, Odyssey, PgCat | | Cloud Poolers | Supabase Supavisor, Neon pooler, RDS Proxy | | App-Level | Prisma connection pool, Drizzle pool, node-postgres Pool | | Monitoring | pg_stat_activity, PgBouncer SHOW commands, Prometheus | | Databases | PostgreSQL 16+, MySQL 8.4+, CockroachDB |
App Instances (100 connections)
↓
PgBouncer (pool_mode = transaction)
max_client_conn = 200
default_pool_size = 20
reserve_pool_size = 5
↓
PostgreSQL (max_connections = 30)
Key: 200 app connections share 20 actual database connections. Each connection is released back to the pool at transaction end.
Optimal pool size = ((core_count * 2) + effective_spindle_count)
Example (8-core server, SSD):
pool_size = (8 * 2) + 1 = 17
For serverless (many short-lived functions):
pgbouncer.default_pool_size = 20
pgbouncer.min_pool_size = 5
app.max_pool_size = 5 (per function instance)
total_functions * 5 <= pgbouncer.max_client_conn
// schema.prisma — pgbouncer mode disables prepared statements
datasource db {
provider = "postgresql"
url = env("DATABASE_URL") // pooler:6543/db?pgbouncer=true
directUrl = env("DIRECT_DATABASE_URL") // direct:5432/db (for migrations)
}
// Connection limit per Prisma instance
generator client {
provider = "prisma-client-js"
}
// At runtime
const prisma = new PrismaClient({
datasources: {
db: { url: process.env.DATABASE_URL },
},
// connection_limit set via URL param: ?connection_limit=5
});
idle_timeout and server_idle_timeout to reclaim stale connectionscl_waiting in PgBouncer; if clients wait, pool is undersized or queries are too slowidle_timeout set to reclaim unused connections (default: 300s)connection_limit per instance is <= pool_size / instance_counttools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.