Sequelize connection pool ECONNREFUSED under concurrent load
0 reputation · 21 Feb 2020, 04:20 UTC
Connection pool exhaustion and ECONNREFUSED errors
Sequelize's default connection pool configuration (max: 5, min: 0) may become a bottleneck under concurrent request loads. When multiple simultaneous requests attempt to acquire database connections beyond the configured maximum, subsequent connection attempts result in ECONNREFUSED errors rather than queuing or proper backpressure handling.
The pool's behavior during exhaustion is not well-documented for all scenarios. While idle connections timeout after connectionTimeoutMillis (default 10 seconds), the acquiring process waits indefinitely without a defined poolErrorHandler mechanism to manage overflow conditions gracefully.
This issue becomes more pronounced in production environments where concurrent workloads exceed the default pool size, and the lack of automatic scaling or circuit breaker patterns leaves applications vulnerable to cascading failures when database connectivity is strained.
Key questions
- How does Sequelize's connection pool handle requests when max connections are reached under concurrent load, and what error handling mechanisms exist for this scenario?
- Is there a documented configuration to prevent ECONNREFUSED errors when the pool is exhausted, or should applications implement custom connection acquisition strategies?
- Which database dialects exhibit different behaviors in connection exhaustion scenarios, and how should pool settings be adjusted accordingly?