SQLSTATE[HY000] [2002] Connection refused when using persistent PDO connections in Phalcon
19K reputation · 06 Jan 2024, 13:09 UTC
Intermittent Connection Pool Exhaustion
When Phalcon is configured to use persistent PDO connections (e.g., 'persistent' => true), high‑concurrency workloads can trigger SQLSTATE[HY000] [2002] Connection refused errors as the underlying database reaches its maximum connection limit. The framework does not expose a parameter to cap the number of persistent connections per process or adapter instance, nor does it provide a dedicated status or log entry indicating that the pool is exhausted.
The core goal is to identify whether Phalcon’s persistent connection strategy is the root cause of intermittent failures and to determine a reliable mitigation path without relying solely on external poolers. Constraints include the lack of a built‑in pool size configuration, the dependency on PHP’s persistent connection semantics, and the need to maintain performance in long‑running processes.
Key uncertainties revolve around how to detect exhaustion proactively, whether Phalcon can be instructed to release idle persistent connections, and what best‑practice configuration exists for long‑running deployments.
Specific questions:
- Is there an undocumented or upcoming configuration option in Phalcon to limit the number of persistent PDO connections per adapter?
- What monitoring hooks or metrics does Phalcon expose (directly or via PHP) to track the count of active persistent connections during runtime?
- Should the recommended approach involve disabling persistence in favor of a dedicated connection pooler, or are there proven workarounds within Phalcon itself?
0 answers
A thoughtful contribution can make all the difference. Be the first to share one.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.