Interview Questions/Troubleshooting Scenarios/Database Connection Exhaustion
IntermediateScenario
10 min

Database Connection Exhaustion

DatabasesConnection PoolingTroubleshooting
Advertisement
Interview Question

Your application logs show frequent database connection pool exhaustion errors. How do you investigate and fix this?

Key Points to Cover
  • Check DB pool settings vs workload
  • Inspect for unclosed connections or long-running queries
  • Increase pool size or optimize queries as needed
  • Add caching or read replicas to reduce load
  • Configure timeouts and retries properly
Evaluation Rubric
Analyzes connection pool usage30% weight
Identifies query/connection issues30% weight
Proposes tuning or scaling fixes20% weight
Mentions caching/replica strategies20% weight
Hints
  • 💡Check ORM connection leak issues.
Common Pitfalls to Avoid
  • ⚠️Only increasing `maxPoolSize` without understanding the underlying cause.
  • ⚠️Focusing solely on application code and neglecting database-level performance issues (e.g., missing indexes).
  • ⚠️Not using proper try-catch-finally or try-with-resources blocks to ensure connections are always closed.
  • ⚠️Ignoring the `connectionTimeout` setting, which can lead to applications waiting indefinitely for a connection that will never become available.
  • ⚠️Failing to set appropriate `idleTimeout` and `maxLifetime` values, which can lead to stale connections being kept in the pool.
Potential Follow-up Questions
  • How would you tune pool sizes?
  • What about retry storms?
Advertisement