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_countdata-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.