mongodb-connection

Configure and troubleshoot MongoDB client connection pools across driver languages.

4|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/minexo79/coser-card-maker --skill mongodb-connection-minexo79
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb-connection
Source: https://github.com/minexo79/coser-card-maker/tree/main/.kilo/skills/mongodb-connection
Command: npx skills add https://github.com/minexo79/coser-card-maker --skill mongodb-connection-minexo79

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Misconfigured MongoDB connection pools cause pool exhaustion, connection churn, timeouts, and wasted server memory. This Skill guides you to size pools and set timeouts based on your actual deployment context instead of blindly copying arbitrary parameter values. ## Core Features & Use Cases - Context-Driven Configuration: Gathers environment details (serverless vs. traditional, OLTP vs. OLAP, concurrency, traffic patterns) before recommending pool sizes and timeout values. - Scenario-Based Recommendations: Provides tuned parameter tables for serverless functions, long-running OLTP servers, analytical workloads, and high-traffic bursty applications. - Connection Troubleshooting: Diagnoses pool exhaustion, ECONNREFUSED and socket timeouts, connection churn, and high latency, separating client config issues from infrastructure problems. - Use Case: A Node.js API deployed on AWS Lambda keeps hitting MongoWaitQueueTimeoutError under load. The Skill walks you through initializing the client outside the handler, setting maxPoolSize to 3-5, and tuning maxIdleTimeMS for warm invocations. ## Quick Start Ask the assistant to review your MongoDB client connection code and recommend pool and timeout settings for your deployment environment.

Frequently Asked Questions about mongodb-connection

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure MongoDB connection pool size?

Estimate pool size with (ops/sec) x (average operation duration) plus 10-20% buffer, or start conservative at 10-20 and adjust based on monitoring. Account for total server connections: instances x (maxPoolSize + 2) x replica set members, with each connection using about 1 MB of server RAM.

How should MongoDB connections work in serverless functions like AWS Lambda?

Initialize the MongoClient outside the handler so it is reused across warm invocations. Use maxPoolSize of 3-5, minPoolSize of 0, and maxIdleTimeMS of 10-30 seconds so idle connections are released quickly between invocations.

Why does MongoWaitQueueTimeoutError happen?

This error signals pool exhaustion: operations are queued because all connections are checked out. Increase maxPoolSize if the server has spare capacity, or optimize slow queries if the server is already saturated.

What is the difference between connectTimeoutMS and socketTimeoutMS in MongoDB?

connectTimeoutMS controls how long the driver waits to establish a new connection, while socketTimeoutMS limits how long an established socket can wait during operations. Set socketTimeoutMS above your slowest expected operation to avoid premature timeouts.

When should I not increase the MongoDB connection pool size?

Do not increase maxPoolSize when the MongoDB server itself is at capacity, since more client connections only add memory pressure. In that case, optimize queries and indexes to shorten operation duration and reduce the connections your workload actually needs.