Logo vun Connection Pool Tuner

Connection Pool Tuner

Organisatioun
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.

Iwwersiicht

EditeurSkillMedev
Repositoryskills
Skill-Nummconnection-pool-tuner
Stären
25
Forks
3
Matgeliwwert Fichieren
Nëmmen Instruktiounen
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • Alles an den Instruktiounen

    Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.

  • Open Source

    Vum SkillMedev op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Connection Pool Tuner an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/SkillMedev/skills/tree/main/skills/connection-pool-tuner
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

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
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Connection Pool Tuner an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Connection Pool Tuner automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Connection Pool Tuner net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

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.

Heefeg gestallte Froen

Wat mécht de KI-Skill 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 retr...

Firwat Connection Pool Tuner op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Connection Pool Tuner besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Connection Pool Tuner an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/SkillMedev/skills/tree/main/skills/connection-pool-tuner an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Connection Pool Tuner benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Connection Pool Tuner benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Connection Pool Tuner domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Connection Pool Tuner gratis?

Jo. De Skill gëtt vum SkillMedev ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇