mongodb-connection

Solid

Optimize MongoDB client connection configuration (pools, timeouts, patterns) for any supported driver language. Use this skill when working/updating/reviewing on functions that instantiate or configure a MongoDB client (eg, when calling `connect()`), configuring connection pools, troubleshooting connection errors (ECONNREFUSED, timeouts, pool exhaustion), optimizing performance issues related to connections. This includes scenarios like building serverless functions with MongoDB, creating API endpoints that use MongoDB, optimizing high-traffic MongoDB applications, creating long-running tasks and concurrency, or debugging connection-related failures.

API & Backend 729 stars 61 forks Updated 2 weeks ago Apache-2.0

Install

View on GitHub

Quality Score: 93/100

Stars 20%
95
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# MongoDB Connection Optimizer You are an expert in MongoDB connection management across all officially supported driver languages (Node.js, Python, Java, Go, C#, Ruby, PHP, etc.). Your role is to ensure connection configurations are optimized for the user's specific environment and requirements, avoiding the common pitfall of blindly applying arbitrary parameters. ## Core Principle: Context Before Configuration **NEVER add connection pool parameters or timeout settings without first understanding the application's context.** Arbitrary values without justification lead to performance issues and harder-to-debug problems. ## Understanding How Connection Pools Work - Connection pooling exists because establishing a MongoDB connection is expensive (TCP + TLS + auth = 50-500ms). Without pooling, every operation pays this cost. - Open connections consume system memory on the MongoDB server instances, ~1 MB per connection on average, even when they are not active. It is advised to avoid having idle connections. **Connection Lifecycle**: Borrow from pool → Execute operation → Return to pool → Prune idle connections exceeding `maxIdleTimeMS`. **Synchronous vs. Asynchronous Drivers**: - **Synchronous** (PyMongo, Java sync): Thread blocks; pool size often matches thread pool size - **Asynchronous** (Node.js, Motor): Non-blocking I/O; smaller pools suffice **Monitoring Connections**: Each MongoClient establishes 2 monitoring connections per replica set member (automatic, separate...

Details

Author
fcakyon
Repository
fcakyon/claude-codex-settings
Created
11 months ago
Last Updated
2 weeks ago
Language
Python
License
Apache-2.0

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

optimizing-database-connection-pooling

This skill optimizes database connection pooling for enhanced performance and resource management. It is activated when the user requests assistance with connection pooling, database performance tuning, or connection lifecycle management. Use this skill to implement and configure connection pools in various programming languages, identify optimal pool settings, and troubleshoot common connection-related issues. The skill is triggered by phrases like "connection pooling," "optimize database connections," or "improve database performance with connection pool."

2,359 Updated today
jeremylongshore
API & Backend Listed

connection-pooling

Use when reasoning about how an application manages its database connections: why every connection has a server-side cost, the difference between application-level pools (HikariCP, pgx pool, node-postgres Pool) and proxy-level pools (PgBouncer, Pgpool, ProxySQL), the three PgBouncer modes (session, transaction, statement) and their feature compatibility, the canonical pool-sizing math (Little's Law applied to database concurrency; Wooldridge's analyses), the failure modes (connection exhaustion, hot-loop reconnects, prepared-statement breakage under transaction pooling, idle-in-transaction leaks), and the diagnostic procedure when a workload is contending on connections instead of query work. Do NOT use for query-level performance (use query-optimization), for index design (use indexing-strategy), for read/write replica routing (use replication-patterns), or for cross-shard query coordination (use sharding-strategy).

0 Updated yesterday
jacob-balslev
API & Backend Listed

mongodb-mongoose

MongoDB with Mongoose — schemas, models, aggregation pipelines, migrations, and Atlas connections. Use when designing collections, writing queries, or integrating MongoDB into Node.js/Next.js apps.

1 Updated today
bg-szy