Agent skill

Optimizing Database Connection Pooling

by jeremylongshore in jeremylongshore/tons-of-skills-marketplace

Process use when you need to work with connection management.

MITAuto-check passedDatabases

Install Optimizing Database Connection Pooling

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-database-connection-pooling -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace optimizing-database-connection-pooling --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/optimizing-database-connection-pooling .claude/skills/optimizing-database-connection-pooling && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
optimizing-database-connection-pooling
GitHub stars
2.8k
Token cost
~1.9k tokens
SKILL.md length
828 words
Files
4 (incl. scripts, references, assets)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Process use when you need to work with connection management.

  • Works in 10 steps: Audit current connection usage by… → Calculate the optimal pool size using… → Configure application-level connection… → …
  • You need to work with connection management
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 3 more sections
  • With phrases like manage connections

What it does

Optimizing Database Connection Pooling is an agent skill from jeremylongshore/tons-of-skills-marketplace. Process use when you need to work with connection management. This skill provides connection pooling and management with comprehensive guidance and automation. Trigger with phrases like "manage connections", "configure pooling", or "optimize connection usage".

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including scripts, reference files and assets (for example `assets/README.md`, `references/README.md` and `scripts/README.md`). Compatibility notes: Designed for Claude Code

It sits in Databases, covering Database administration. It works with PostgreSQL. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • You need to work with connection management
  • With phrases like manage connections
  • Configure pooling
  • Optimize connection usage

Example prompts

  • “manage connections”
  • “configure pooling”
  • “optimize connection usage”
  • “/optimizing-database-connection-pooling”

Requirements

  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*)

Workflow steps

10 steps, taken from the first numbered list in SKILL.md.

  1. Audit current connection usage by querying active connections
  2. Calculate the optimal pool size using the formula: pool_size = (core_count * 2) + effective_spindle_count. For SSD-backed databases, use…
  3. Configure application-level connection pool parameters
  4. For PostgreSQL with many application instances, deploy PgBouncer in transaction pooling mode
  5. For MySQL with many application instances, deploy ProxySQL
  6. Set max_connections in the database server based on available memory. Each PostgreSQL connection uses approximately 5-10MB of memory. For…
  7. Implement connection health checks. Configure the pool to validate connections before lending (testOnBorrow or validation-query). Use a…
  8. Monitor connection pool metrics continuously
  9. Handle connection storms (sudden spike in connection requests) by configuring a connection request queue with a bounded wait time…
  10. Document the connection architecture: application pool size per instance, number of application instances, PgBouncer/ProxySQL settings…

What it can do on your machine

Read from SKILL.md and the folder at commit 23ea8d4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Grep
    • Glob
    • Bash(psql:*)
    • Bash(mysql:*)
    • Bash(mongosh:*)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/, which the agent can run.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com
    • pgbouncer.org
    • proxysql.com
    • postgresql.org

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Optimizing Database Connection Pooling loads about 1.9k tokens when it runs, and up to ~2.1k if it reads all its reference files. Until then it costs about 75 tokens; SKILL.md has 828 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~75
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 23ea8d4, republished under its MIT licence (© jeremylongshore). 828 words, ~1,930 tokens.

Download SKILL.mdSave it as .claude/skills/optimizing-database-connection-pooling/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
optimizing-database-connection-pooling
description
Process use when you need to work with connection management. This skill provides connection pooling and management with comprehensive guidance and automation. Trigger with phrases like "manage connections", "configure pooling", or "optimize connection usage".
allowed-tools
Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*)
compatibility
Designed for Claude Code
version
1.23.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
database, optimizing-database

Database Connection Pooler

Overview

Configure and optimize database connection pooling using external poolers (PgBouncer, ProxySQL, Odyssey) and application-level pool settings to prevent connection exhaustion, reduce connection overhead, and improve database throughput.

Prerequisites

  • psql or mysql CLI for querying connection metrics
  • Access to database configuration files (postgresql.conf, my.cnf) for max_connections settings
  • PgBouncer, ProxySQL, or Odyssey installed if using external pooling
  • Application connection pool settings accessible (database URL, pool size parameters)
  • Server CPU core count and available memory for pool sizing calculations

Instructions

  1. Audit current connection usage by querying active connections:

    • PostgreSQL: SELECT count(*) AS total, state, usename FROM pg_stat_activity GROUP BY state, usename ORDER BY total DESC
    • MySQL: SHOW STATUS LIKE 'Threads_connected' and SHOW PROCESSLIST
    • Compare against max_connections setting to determine headroom
  2. Calculate the optimal pool size using the formula: pool_size = (core_count * 2) + effective_spindle_count. For SSD-backed databases, use core_count * 2 + 1. A 4-core server with SSD storage should have a pool size of approximately 9. This formula applies per application instance.

  3. Configure application-level connection pool parameters:

    • minimumIdle: Set to 2-5 for low-traffic periods (avoids cold-start latency)
    • maximumPoolSize: Set using the formula from step 2
    • connectionTimeout: 5-10 seconds (fail fast rather than queue indefinitely)
    • idleTimeout: 10-30 minutes (release idle connections back to pool)
    • maxLifetime: 30 minutes (prevent stale connections from accumulating)
    • leakDetectionThreshold: 60 seconds (log warning for connections held too long)
  4. For PostgreSQL with many application instances, deploy PgBouncer in transaction pooling mode:

    • Set pool_mode = transaction to multiplex connections (one backend connection serves many clients between transactions)
    • Set default_pool_size = 20 and max_client_conn = 1000
    • Configure server_idle_timeout = 600 to close unused backend connections
    • Set server_lifetime = 3600 to periodically refresh connections
  5. For MySQL with many application instances, deploy ProxySQL:

    • Configure connection multiplexing in mysql_servers table
    • Set max_connections per backend server
    • Configure query rules for read/write splitting to replicas
    • Enable connection pooling with free_connections_pct = 10
  6. Set max_connections in the database server based on available memory. Each PostgreSQL connection uses approximately 5-10MB of memory. For a server with 8GB RAM: max_connections = (8192MB - 2048MB_for_OS - 2048MB_shared_buffers) / 10MB = ~400. For MySQL, each thread uses approximately 1-4MB.

  7. Implement connection health checks. Configure the pool to validate connections before lending (testOnBorrow or validation-query). Use a lightweight query: SELECT 1 for MySQL or a simple query for PostgreSQL. Set validation interval to avoid excessive overhead.

  8. Monitor connection pool metrics continuously:

    • Active connections vs. pool size (saturation indicator)
    • Wait time for connection acquisition (queuing indicator)
    • Connection creation rate (churn indicator)
    • Idle connection count (waste indicator)
    • Connection leak warnings (application bug indicator)
  9. Handle connection storms (sudden spike in connection requests) by configuring a connection request queue with a bounded wait time, implementing retry with exponential backoff in the application, and pre-warming the pool during application startup.

  10. Document the connection architecture: application pool size per instance, number of application instances, PgBouncer/ProxySQL settings, database max_connections, and the maximum theoretical connections formula (instances * pool_size_per_instance).

Show full SKILL.md (352 more words)Show less

Output

  • PgBouncer/ProxySQL configuration files with optimized pool settings
  • Application pool configuration with connection string and pool parameters
  • Connection sizing worksheet documenting the calculation from cores to pool size
  • Monitoring queries for connection metrics and health checks
  • Connection architecture diagram showing application -> pooler -> database flow

Error Handling

ErrorCauseSolution
FATAL: too many connections for roleApplication pool size exceeds max_connections or connection leakReduce pool size; fix connection leaks (enable leak detection); add PgBouncer for connection multiplexing
Connection timeout after 5 secondsPool exhausted, all connections in useIncrease pool size cautiously; check for long-running transactions holding connections; add connection queue with backpressure
connection reset by peer errorsServer-side idle timeout killed the connectionSet pool maxLifetime shorter than server idle_in_transaction_session_timeout; enable connection validation
PgBouncer no more connections allowedmax_client_conn exceededIncrease max_client_conn; or reduce client connection demand; check for connection leaks in application
High connection churn (create/destroy rate)Pool too small for workload or maxLifetime too shortIncrease pool size; extend maxLifetime to 30 minutes; ensure minimumIdle is set to avoid constant pool resizing

Examples

Right-sizing a pool for a Spring Boot microservice: 4-core server, SSD storage, 3 microservice instances. Optimal pool per instance: (4 * 2) + 1 = 9. Total connections: 9 * 3 = 27. Database max_connections = 100 with comfortable headroom. Application startup pre-warms 5 connections per instance. Connection leak detection set to 60 seconds catches a missing connection.close() in an error handler.

PgBouncer deployment for a serverless application: Lambda functions create a new database connection per invocation, overwhelming PostgreSQL with 500+ connections. PgBouncer deployed between Lambda and PostgreSQL with pool_mode = transaction, default_pool_size = 25, max_client_conn = 5000. Lambda connects to PgBouncer; PgBouncer multiplexes to 25 backend connections. Connection errors eliminated; database CPU reduced from 95% to 30%.

ProxySQL read/write splitting: A MySQL application sends 80% reads and 20% writes. ProxySQL routes writes to the primary and distributes reads across 2 replicas. Connection pooling reduces backend connections from 300 (direct) to 60 (pooled). Average query latency drops from 8ms to 3ms due to reduced connection overhead.

Resources

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (scripts, references, assets) in skills/.curated/optimizing-database-connection-pooling of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • assets/README.md
  • references/README.md
  • scripts/README.md

Open the folder on GitHubat commit 23ea8d4

Compare with similar skills

Optimizing Database Connection Pooling next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Optimizing Database Connection Pooling compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Optimizing Database Connection Pooling this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.9kAutomated safety check: PassMIT
DB AdminEliasOulkadi/shokunin114—~2kAutomated safety check: NotesMIT
Postgres Expertcin12211/orca-q224—~5.5kAutomated safety check: PassMIT
Mg Railway DB Restoremodelguide/modelguide108—~562Automated safety check: PassMIT
Postgres ExpertRightNow-AI/openfang18k—~830Automated safety check: PassApache-2.0
Postgres Optimizationrohitg00/awesome-claude-code-toolkit2.7k—~1.1kAutomated safety check: PassApache-2.0

Similar skills

  • DB Admin

    EliasOulkadi/shokunin

    PostgreSQL database administration — backup/restore (pgdump, PITR, WAL archiving), health monitoring (connections, bloat, cache hit ratio, dead tuples), connection pooling (PgBouncer), replication…

    114 GitHub stars~2k tokensUpdated 3 days ago
    DatabasesAuto-check: notes
  • Postgres Expert

    cin12211/orca-q

    PostgreSQL query optimization, JSONB operations, advanced indexing strategies, partitioning, connection management, and database administration.

    224 GitHub stars~5.5k tokensUpdated 17 days ago
    DatabasesAuto-check passed
  • Mg Railway DB Restore

    modelguide/modelguide

    Restore a PostgreSQL database backup to a Railway environment.

    108 GitHub stars~562 tokensUpdated 3 mo ago
    DatabasesAuto-check passed
  • Postgres Expert

    RightNow-AI/openfang

    PostgreSQL expert for query optimization, indexing, extensions, and database administration

    18k GitHub stars~830 tokensUpdated 3 mo ago
    DatabasesAuto-check passed
  • Postgres Optimization

    rohitg00/awesome-claude-code-toolkit

    PostgreSQL optimization including indexes, query plans, partitioning, JSONB operations, and connection pooling

    2.7k GitHub stars~1.1k tokensUpdated 4 mo ago
    DatabasesAuto-check passed
  • Digoal

    digoal/blog

    Portable digital employee distilled from digoal's personal blog for PostgreSQL, PolarDB, DuckDB, AI+database, vector/RAG, database operations, source-code reading, technical content creation…

    8.6k GitHub stars~2.2k tokensUpdated 10 days ago
    DatabasesAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Analyzing Text With NLP

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to perform natural language processing and text analysis using the nlp-text-analyzer plugin.

    2.8k GitHub starsUsed in 1 repo~819 tokens
    Auto-check passed
  • Building Neural Networks

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Detecting Data Anomalies

    jeremylongshore/tons-of-skills-marketplace

    Process identify anomalies and outliers in datasets using machine learning algorithms.

    2.8k GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check passed
  • Explaining Machine Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill enables AI assistant to provide interpretability and explainability for machine learning models.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Optimizing Prompts

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed

Works with

Categories

Questions about Optimizing Database Connection Pooling

What does Optimizing Database Connection Pooling do?

Process use when you need to work with connection management. Optimizing Database Connection Pooling is an agent skill from jeremylongshore/tons-of-skills-marketplace. Process use when you need to work with connection management.

When should I use Optimizing Database Connection Pooling?

Optimizing Database Connection Pooling fits situations like: you need to work with connection management; with phrases like manage connections; configure pooling; optimize connection usage.

How do I install Optimizing Database Connection Pooling in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-database-connection-pooling -a claude-code`. Or copy the skill folder (skills/.curated/optimizing-database-connection-pooling in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/optimizing-database-connection-pooling in your project. Claude Code loads it when a task matches its description.

How do I install Optimizing Database Connection Pooling in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-database-connection-pooling -a codex`. Or copy the skill folder (skills/.curated/optimizing-database-connection-pooling in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/optimizing-database-connection-pooling in your project. Codex loads it when a task matches its description.

Can I use Optimizing Database Connection Pooling in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill optimizing-database-connection-pooling -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/optimizing-database-connection-pooling, .gemini/skills/optimizing-database-connection-pooling, .github/skills/optimizing-database-connection-pooling and .opencode/skills/optimizing-database-connection-pooling in your project.

What does Optimizing Database Connection Pooling need to run?

SKILL.md names no scripts, command-line tools or credentials: Optimizing Database Connection Pooling is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*), Bash(mongosh:*). Compatibility (from SKILL.md): Designed for Claude Code.

Does Optimizing Database Connection Pooling access the network?

SKILL.md names 4 domains. As links in the text: github.com, pgbouncer.org, proxysql.com and postgresql.org. This is read from the text; nothing was executed.

Is Optimizing Database Connection Pooling safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Optimizing Database Connection Pooling use?

Optimizing Database Connection Pooling is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Optimizing Database Connection Pooling use?

About 1.9k tokens (SKILL.md is roughly 7.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 146 tokens, read only when the agent opens those files.

What are the alternatives to Optimizing Database Connection Pooling?

Skills that share tags, products or a category with Optimizing Database Connection Pooling: DB Admin (EliasOulkadi/shokunin, 114 stars), Postgres Expert (cin12211/orca-q, 224 stars), Mg Railway DB Restore (modelguide/modelguide, 108 stars) and Postgres Expert (RightNow-AI/openfang, 18k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Optimizing Database Connection Pooling?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,821 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 8, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.