We are here to assist you.
Health Advisor
+91-8877772277Available 7 days a week
10:00 AM – 6:00 PM to support you with urgent concerns and guide you toward the right care.
Join our healthcare community
cardiologist
21 years experience
Common questions about Dr. Ayush
₹200
Home Visit Fee
Yes — setting `minPoolSize: 0` in MongoDB/Mongoose can affect speed, but mostly in specific situations.
### What `minPoolSize` does
`minPoolSize` defines the **minimum number of connections MongoDB keeps open** in the connection pool.
Example:
```js mongoose.connect(uri, { maxPoolSize: 20, minPoolSize: 0 }) ```
With `minPoolSize: 0`:
* No idle connections are kept alive unnecessarily * Connections can close when not being used * New requests may need to reopen connections later
---
# Speed Impact
## ✅ Pros of `minPoolSize: 0`
### Better for:
* Serverless apps (like Vercel functions) * Low traffic apps * Saving memory/resources * Preventing too many idle DB connections
### Result:
Lower resource usage.
---
## ❌ Cons
### Can increase latency on:
* First request after inactivity * Burst traffic after idle periods
Because MongoDB may need to:
1. Create new socket connections 2. Authenticate again 3. Warm up TLS/DNS
That can add:
* ~20ms–200ms extra latency * Sometimes more on cold starts
---
# In High Traffic Apps
If your app gets continuous traffic:
* `minPoolSize: 0` usually has very little negative effect * Pool stays naturally warm because requests keep connections active
---
# Recommended Usage
## For Next.js + MongoDB Atlas
Usually good:
```js maxPoolSize: 20, minPoolSize: 0 ```
Especially if:
* You cache the mongoose connection globally * You're on serverless * Traffic is moderate
---
## For very high-performance APIs
You might use:
```js minPoolSize: 5 ```
This keeps some connections always ready and reduces cold latency.
---
# Important Thing
`minPoolSize` is usually NOT the reason for major slowness.
Much bigger performance factors are:
* Missing DB indexes * `.populate()` overuse * No `.lean()` * Large payloads * SSR hitting DB every request * N+1 queries * Bad aggregation pipelines * No caching
Those affect performance far more than `minPoolSize`.
Yes — setting `minPoolSize: 0` in MongoDB/Mongoose can affect speed, but mostly in specific situations.
### What `minPoolSize` does
`minPoolSize` defines the **minimum number of connections MongoDB keeps open** in the connection pool.
Example:
```js mongoose.connect(uri, { maxPoolSize: 20, minPoolSize: 0 }) ```
With `minPoolSize: 0`:
* No idle connections are kept alive unnecessarily * Connections can close when not being used * New requests may need to reopen connections later
---
# Speed Impact
## ✅ Pros of `minPoolSize: 0`
### Better for:
* Serverless apps (like Vercel functions) * Low traffic apps * Saving memory/resources * Preventing too many idle DB connections
### Result:
Lower resource usage.
---
## ❌ Cons
### Can increase latency on:
* First request after inactivity * Burst traffic after idle periods
Because MongoDB may need to:
1. Create new socket connections 2. Authenticate again 3. Warm up TLS/DNS
That can add:
* ~20ms–200ms extra latency * Sometimes more on cold starts
---
# In High Traffic Apps
If your app gets continuous traffic:
* `minPoolSize: 0` usually has very little negative effect * Pool stays naturally warm because requests keep connections active
---
# Recommended Usage
## For Next.js + MongoDB Atlas
Usually good:
```js maxPoolSize: 20, minPoolSize: 0 ```
Especially if:
* You cache the mongoose connection globally * You're on serverless * Traffic is moderate
---
## For very high-performance APIs
You might use:
```js minPoolSize: 5 ```
This keeps some connections always ready and reduces cold latency.
---
# Important Thing
`minPoolSize` is usually NOT the reason for major slowness.
Much bigger performance factors are:
* Missing DB indexes * `.populate()` overuse * No `.lean()` * Large payloads * SSR hitting DB every request * N+1 queries * Bad aggregation pipelines * No caching
Those affect performance far more than `minPoolSize`.
MBBS
21 years of experience
Home Visits Available
ActiveThis doctor offers home consultation services for patients who cannot visit the clinic.