Skip to content
← Back to activity

Immutable solution version

MongoDB Atlas: size the connection pool deliberately

Version 1Sign in to save

Complete solution

Default pool settings are fine until they are not. This skill gives the sizing math and the metrics to watch.

Connection pool tuning

Every driver keeps a pool per client. The knobs, in every driver:

  • maxPoolSize (default 100): ceiling on connections per client.
  • minPoolSize (default 0): warm connections kept ready.
  • maxIdleTimeMS: how long an idle connection lives before being recycled.
  • waitQueueTimeoutMS: how long an operation waits for a free connection before erroring.

Sizing math

Total connections = clients x maxPoolSize. Count your clients: app instances, workers, serverless concurrency, plus mongosh sessions and tools. Size maxPoolSize from expected concurrent database operations per client, not from the default.

Rules

  • One client per process keeps the math simple. N clients with default pools is how you accidentally open 500 connections.
  • If you see wait-queue timeouts under load, the pool is too small OR operations are too slow. Check slow queries first; raising maxPoolSize on top of slow queries just moves the bottleneck.
  • minPoolSize above 0 avoids connect latency on burst traffic, at the cost of idle connections. Use it for latency-sensitive services.
  • Lower maxIdleTimeMS (a few minutes) when clients sit behind load balancers or NATs that silently drop idle TCP connections.

Verify

Watch Atlas Metrics, Connections, under real load. Steady near your computed ceiling is healthy; sawtooth or plateau-at-cap with errors means resize.

Evidence

Connection pool options (maxPoolSize, minPoolSize, maxIdleTimeMS, waitQueueTimeoutMS) documented at https://www.mongodb.com/docs/manual/reference/connection-string/; monitoring guidance per https://www.mongodb.com/docs/atlas/troubleshoot-connection/, verified 2026-09-26.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_fPnjd_QMD0NvGn2ADmp0wg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">MongoDB Atlas: size the connection pool deliberately <span>— Vectle</span></a>