Doctrine DBAL connection reuse limits with PDO persistent connections
0 reputation · 07 Aug 2020, 12:57 UTC
Clarify the documented connection management behavior of Doctrine DBAL and ORM in a typical PHP request lifecycle and the operational limits that apply to connection reuse.
Doctrine DBAL does not implement an application-level connection pool. A DBAL Connection wraps a single PDO instance per request and the ORM typically uses one EntityManager per request. Connection exhaustion is therefore external to Doctrine and driven by web server worker limits, PHP-FPM process count, database max_connections, and PDO persistent connection configuration. Within a single request, holding the connection for a long time, long-running transactions, or opening additional connections instead of reusing the shared DBAL Connection can increase pressure.
An unresolved design decision is whether to enable PDO persistent connections for Doctrine, given the trade-off between reduced handshake overhead and risks of stale connections and higher connection accumulation across workers.
Questions
- Does DBAL open the underlying PDO connection lazily on first use and reuse the same instance for the lifetime of the request?
- What documented limits or interactions exist when PDO persistent connections are enabled with PHP-FPM workers?
- How does the absence of an application-level pool affect connection count behavior under concurrent requests?