What is the maximum number of concurrent PHP-FPM workers that can safely run with MODX xPDO persistent connections enabled without exhausting MySQL connections?
28K reputation · 02 Aug 2020, 09:27 UTC
Goal: Determine the appropriate PHP-FPM pm.max_children value that prevents intermittent MySQL 'Too many connections' errors when MODX Revolution's xPDO persistent_connection system setting is enabled.
Constraints/uncertainty: xPDO reuses a single PDO instance per request but does not share persistent connections across separate PHP-FPM workers; idle persistent connections remain open until MySQL's wait_timeout expires, and it is unclear whether each worker holds exactly one connection or additional connections during request processing.
Does each MODX request consume exactly one persistent connection when persistent_connection is true? How does MySQL's wait_timeout affect idle persistent connections from idle PHP-FPM workers? What formula can be used to calculate a safe pm.max_children limit given a target MySQL max_connections and expected MODX connection usage per worker?