Q47: How does Connection Pooling work in Mongoose and MongoDB drivers?

Opening database connections is computationally expensive. MongoDB drivers maintain a Connection Pool—a cached cache of open socket connections reused for database requests. Configured via maxPoolSize (default 100 in modern drivers) and minPoolSize options.

Key Takeaways
  • Reuses cached socket connections.
  • Set maxPoolSize based on application concurrency needs.
Knowledge Check

What is the default maxPoolSize in modern MongoDB drivers?