connection-pool
Skill2 starsChanged 4 months agoMITView on GitHub
Configure or fix a database/HTTP connection pool — right-size it, set acquire/idle/lifetime timeouts, and avoid exhaustion and leaked connections — so the app stays responsive under load instead of stalling on connection waits. Use when the user says "configure the connection pool", "tune pool size", "I'm getting pool timeout / too many connections", "connections are leaking", "size the DB pool", or "the app hangs waiting for a connection".
In this repository68 other files it gives its agents.
- a11ySkill
- api-docsSkill
- audit-logSkill
- benchmarkSkill
- bisectSkill
- cacheSkill
- changelogSkill
- cherry-pickSkill
- ci-setupSkill
- codeownersSkill
- commit-messageSkill
- contributingSkill
- coverageSkill
- db-migrateSkill
- dead-codeSkill
- debugSkill
- depsSkill
- diagramSkill
- dockerizeSkill
- docstringSkill
- e2eSkill
- env-exampleSkill
- error-handlingSkill
- explainSkill
- feature-flagSkill
- flaky-testSkill
- gitignoreSkill
- graceful-shutdownSkill
- graphqlSkill
- healthcheckSkill
- i18nSkill
- idempotencySkill
- licenseSkill
- lint-fixSkill
- loggingSkill
- migrateSkill
- mockSkill
- onboardSkill
- optimizeSkill
- paginationSkill
- pr-descriptionSkill
- pre-commitSkill
- profileSkill
- prune-branchesSkill
- rate-limitSkill
- readmeSkill
- rebaseSkill
- refactorSkill
- regexSkill
- releaseSkill
- resolve-conflictsSkill
- retrySkill
- review-diffSkill
- scaffoldSkill
- secrets-scanSkill
- security-headersSkill
- seedSkill
- soft-deleteSkill
- sqlSkill
- squashSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Always set acquire, idle, max-lifetime, and connection timeouts so saturation fails fast and stale connections are recycled — never an …
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Pool library & configuration signals
!grep -rilE "pool|Pool|maxConnections|max_connections|pool_size|max_overflow|HikariCP|pgbouncer|pg-pool|sequelize|typeorm|sqlalchemy|prisma|knex|connection_limit|maxPoolSize|idleTimeout|acquireTimeout" --include='*.*' package.json pyproject.toml go.mod Gemfile application.properties 2>/dev/null | grep -vE 'node_modules|\.git|dist|build' | head -8
Instructions
Configure the connection pool in $ARGUMENTS so it serves load without exhausting the backing resource or hanging on connection acquisition. The common failure is a pool that's mis-sized or has no timeouts — requests queue forever, or the database refuses connections. Reuse the project's existing pool library rather than adding another.
Method
- Understand the ceiling. The pool's max size is bounded by the server's limit, not the app's wishes. For Postgres, total connections across all app instances must stay under
max_connections(minus reserved superuser slots).pool_max × instance_count ≤ server_max— account for every replica, worker, and serverless invocation. - Right-size, don't over-size. Bigger is not faster: past the point where the DB can do useful concurrent work (roughly its core/disk parallelism), more connections add contention and memory, not throughput. Start from a modest max (often far smaller than expected — e.g. HikariCP's guidance of ~
cores × 2for CPU-bound DBs) and raise only if profiling shows connection wait, not DB saturation. - Set every timeout — this is what prevents hangs:
- acquire/checkout timeout: fail fast (e.g. a few seconds) when no connection is free, so a request errors instead of hanging forever and piling up.
- idle timeout: return unused connections so the pool shrinks under low load.
- max lifetime: recycle connections periodically so a stale/half-dead connection (or one severed by a DB-side/idle-timeout or a load balancer) is retired before it's handed out.
- connection/validation timeout: bound how long establishing/testing a connection can take.
- Prevent leaks. Every checkout must be released on all paths including errors — use the library's scoped/
using/try-finally/middleware pattern so an exception doesn't strand a connection. A steadily growing "in use" count with idle load is a leak; enable leak detection if the library offers it. - Consider an external pooler for high fan-out. Many app instances or serverless functions each holding a pool will overwhelm Postgres — front it with PgBouncer (transaction pooling) or the platform's proxy, and keep per-instance pools small.
- Match graceful shutdown. Drain and close the pool on shutdown so connections are released cleanly (see the
graceful-shutdownskill), and surface pool metrics (in-use, idle, wait time) for observability. - Verify. Load-test to confirm the pool doesn't exhaust under expected concurrency, that acquisition fails fast rather than hanging when saturated, and that in-use returns to zero at idle (no leak).
Rules
- Size the pool against the server's connection ceiling across all instances (
pool_max × instances ≤ server_max), not per-app in isolation. - Bigger pools aren't faster past the DB's real concurrency — right-size from a modest max and grow only on evidence of connection wait, not DB saturation.
- Always set acquire, idle, max-lifetime, and connection timeouts so saturation fails fast and stale connections are recycled — never an unbounded wait.
- Guarantee release on every path (including errors); a monotonically rising in-use count is a leak, not load.
- For high instance/serverless fan-out use an external pooler, close the pool on shutdown, and end by summarizing the sizes, timeouts, leak-safety, and the server-limit headroom.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

