Connection Pool Tuner logo

Connection Pool Tuner

Organization
SkillMedev
connection-pool-tuner

Diagnoses connection pool exhaustion from captured evidence and sets correct pool sizes and timeouts across app pools and PgBouncer. Use when someone says "we keep hitting database connection limit errors under load", "my API times out waiting for a connection from the pool", "the database shows hundreds of idle connections", or sees "too many clients", checkout/acquire timeouts, "idle in transaction" pile-up, or serverless functions storming the database on a traffic spike. Do NOT use when the problem is an unreliable external service (third-party API, downstream microservice) needing retries or fallbacks - use circuit-breaker-builder instead.

Overview

PublisherSkillMedev
Repositoryskills
Skill nameconnection-pool-tuner
Stars
25
Forks
3
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by SkillMedev on GitHub. Read the source before you install it.

Installation

Install the Connection Pool Tuner AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/SkillMedev/skills/tree/main/skills/connection-pool-tuner
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SkillMedev/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/connection-pool-tuner .claude/skills/connection-pool-tuner
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Connection Pool Tuner in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Connection Pool Tuner on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Connection Pool Tuner is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Connection Pool Tuner

Pool exhaustion shows up as checkout timeouts and "too many clients" errors; the fix is almost never "raise max_connections." Diagnose from evidence first, then size to the database.

Workflow

  1. Capture the evidence before touching any number. Query pg_stat_activity grouped by state under load. Record total connections, count per state, and the longest-running query/transaction age. Also record every pool that points at the DB: app replicas times per-replica pool size, plus migrations and any superuser sessions.

  2. Classify the failure from the evidence:

    • Many idle in transaction rows -> code opens a transaction and does slow work (an HTTP call, sleep, batch) before commit. Fix the transaction scope, not the pool.
    • Many active long-runners -> slow queries saturating connections. Tune the queries.
    • Checkout/acquire timeouts while DB connections sit mostly idle -> the app pool is too small or connections leak (not returned to the pool). Find the leak before enlarging.
    • Total connections at or above max_connections -> the sum of pools is too large; reduce per-replica pool or front with a proxy. Do not raise max_connections.
  3. Size the pool to the database, not the app. Postgres performs best at a small connection count; each backend is a process with real memory cost. Target tens of active connections, not thousands; a common ceiling is roughly (core_count * 2) + effective_spindle_count. The sum of all pools must stay under max_connections with headroom for migrations and superuser - keep at least 10-15% of max_connections free. Twenty replicas with a pool of 20 each is 400 connections - usually far too many.

  4. Set timeouts that fail fast. Set a pool checkout/acquire timeout (2-5s) so a request errors instead of piling up. Set idle_in_transaction_session_timeout (30-60s is a sane starting range for web workloads) to kill stuck transactions. Set statement_timeout to cap runaway queries - anchor it to your slowest legitimate query plus headroom, often 30s for OLTP paths. In HikariCP, set connectionTimeout and keep maxLifetime a minute or two below the DB/proxy idle cutoff so you never hand out a dead socket.

  5. Multiplex with PgBouncer when connection count is the bottleneck. Run PgBouncer in transaction pooling mode to fold many client connections onto few server connections. Transaction mode forbids session-level features - prepared-statement caches, SET, advisory locks held across statements - so configure clients accordingly.

  6. Tame serverless storms. Serverless/Lambda functions each open their own connection and storm the DB on a spike. Route them through PgBouncer or a serverless pooler/driver (Neon or Supabase pooler, RDS Proxy, Prisma Accelerate) and keep per-function pool size at 1.

  7. Verify under load. Re-run the pg_stat_activity query and confirm the failing state is gone and total connections sit safely under max_connections.

Deliverable

Produce a tuning record alongside the config change: the before/after pg_stat_activity readings, the failure classification from step 2 with the evidence that supports it, the full connection budget (every pool times its replicas, plus migration/superuser headroom, summed against max_connections), and each changed setting - pool size, checkout timeout, idle_in_transaction_session_timeout, statement_timeout, maxLifetime, PgBouncer mode - with its one-line justification. The record proves the change fixed the diagnosed cause rather than masking it.

Quality bar

  • Every size or timeout change is justified by a captured pg_stat_activity reading, not a guess.
  • The sum of all pools, plus migration and superuser headroom, stays under max_connections.
  • Each failure mode is traced to its real cause (transaction scope, slow query, or leak) before any pool is enlarged.

Do NOT

  • Do NOT raise max_connections or enlarge the pool as the first move - that masks a leak or a slow transaction and adds per-backend memory pressure.
  • Do NOT prescribe numbers without a captured pg_stat_activity reading.
  • Do NOT budget pools per replica in isolation - the database sees the sum across every replica, sidecar, and cron job, and that sum is what exhausts max_connections.
  • Do NOT use transaction-mode PgBouncer with clients that rely on session prepared statements, SET, or cross-statement advisory locks unless reconfigured.
  • Do NOT leave per-function serverless pools larger than 1.
  • Do NOT use this skill for external-service flakiness (retries, fallbacks, backoff) - that is circuit-breaker-builder's job.

Defaults to reach for

Start small: an app pool of 5-10 per replica, a checkout timeout of 2-5s, and a proxy in transaction mode if connection count is the bottleneck. If raising the pool fixes latency, you had a leak or a slow transaction - find it rather than masking it.

Frequently asked questions

What does the Connection Pool Tuner AI skill do?

Diagnoses connection pool exhaustion from captured evidence and sets correct pool sizes and timeouts across app pools and PgBouncer. Use when someone says "we keep hitting database connection limit errors under load", "my API times out waiting for a connection from the pool", "the database shows hundreds of idle connections", or sees "too many clients", checkout/acquire timeouts, "idle in transaction" pile-up, or serverless functions storming the database on a traffic spike. Do NOT use when the problem is an unreliable external service (third-party API, downstream microservice) needing retr...

Why use Connection Pool Tuner on TypingMind?

Because you install it once and use it with any model. Connection Pool Tuner is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Connection Pool Tuner in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/SkillMedev/skills/tree/main/skills/connection-pool-tuner. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Connection Pool Tuner?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Connection Pool Tuner?

As many as you like. As long as a model supports skills, you can use Connection Pool Tuner with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Connection Pool Tuner AI skill free?

Yes. It is published on GitHub by SkillMedev under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇