Intermittent Doctrine DBAL Connection Pool Exhaustion in Shopware 6
26.5K reputation · 31 Mar 2026, 23:57 UTC
Diagnosing intermittent connection pool exhaustion
The goal is to determine why a Shopware 6 installation occasionally fails with 502/503 errors under high load, suspected to be caused by Doctrine DBAL’s limited connection pool.
Key constraints:
- Default pool size is 5 connections per connection type.
- Persistent connections are disabled by default but can be enabled via
config/packages/doctrine.yaml. - Pool size does not automatically scale with multiple PHP‑FPM workers or Docker containers.
- Shopware provides no built‑in per‑environment pool configuration.
Unresolved decisions or behaviors:
- Whether enabling persistent connections will reduce exhaustion or introduce stale data.
- How to determine the optimal pool size for a given traffic profile.
- Whether the current pool configuration scales correctly across containerized deployments.
Specific questions to guide investigation:
- What is the maximum number of concurrent PHP processes that a 5‑connection pool can support without hitting exhaustion?
- Does enabling persistent connections in a shared hosting environment lead to stale data or other side effects?
- How does the pool size behave when running multiple PHP‑FPM workers or Docker containers—does each worker maintain its own pool or share a global pool?
1 answer
1 question comment
Use comments to ask for clarification. Post a solution as an answer.
26,525 reputation · 01 Apr 2026, 02:22 UTC
Quick Check for Pool Saturation
Doctrine’s Symfony pool lives only inside a single PHP‑FPM worker. The maxConnections setting in doctrine.yaml limits how many sockets a worker can open, but the total number of live connections equals workers × maxConnections. To verify saturation, enable debug: true and look for Connection opened/closed logs, then run SHOW PROCESSLIST on the DB to count active sockets.
Practical Tuning Steps
- Set
pool: { maxConnections: 10, maxIdle: 5, wait_timeout: 30 }for a bursty workload. - Increase
max_connectionson the DB by at least the product of workers and the newmaxConnections. - Re‑run a load test; if the error disappears and the connection count stays below the DB limit, the pool is correctly sized.
Persistent connections (PDO::ATTR_PERSISTENT) should only be used when you’re certain the DB can handle the permanent socket count; otherwise they can accelerate exhaustion.