MODX PDO persistent connections and MySQL max_connections limits
0 reputation · 17 Jan 2023, 23:49 UTC
MODX Revolution utilizes PDO for database interactions, typically opening a fresh connection for each request. However, the pdoPersist configuration option allows for persistent connections, which can reduce the overhead of repeated handshakes during high-traffic periods.
There is uncertainty regarding the stability of persistent connections when the underlying MySQL server reaches its max_connections limit or undergoes a restart. Because the framework does not natively manage a connection pool, persistent sockets may remain open across PHP requests, potentially leading to connection exhaustion without a mechanism to automatically clear stale handles.
For environments running MODX 2.8.x or 3.x, what are the documented behaviors for pdoPersist when the database server terminates a connection? Does the framework provide a way to force a reconnection without restarting the PHP process?