Modern PHP 8.x & Internals
8-10 Years (Tech Lead)
Hard
Production Scenario
Explain the difference between `Pdo` connection pooling vs persistent connections (`PDO::ATTR_PERSISTENT`) in PHP-FPM.
Real-World Scenario / Incident Description
Under 5,000 req/sec, MySQL threw "Too many connections" (Error 1040) while PHP-FPM was configured with `PDO::ATTR_PERSISTENT => true`.
692 views
•
Updated 1 month ago
The Persistent Connection Danger in PHP-FPM
With PDO::ATTR_PERSISTENT, each PHP-FPM worker process keeps its own persistent database connection open even after the request terminates.
- If you have 500 PHP-FPM workers across 4 web servers, that equals 2,000 persistent idle database connections.
- Solution: Use dedicated external connection poolers (like ProxySQL for MySQL or PgBouncer for PostgreSQL) rather than in-process persistent PDO connections.
Related Concepts:
#PDO
#Persistent Connections
#Connection Pooling
#MySQL
More Modern PHP 8.x & Internals Interview Questions
How does the Zend Engine manage memory with Zvals, Reference Counting, and the Circular Garbage Collector in PHP 8.x?
Read →
Explain PHP 8.4 Asymmetric Visibility, Property Hooks, and Constructor Property Promotion.
Read →
How does the JIT (Just-In-Time) compiler in PHP 8.x work, and why does it benefit CPU-heavy tasks but not typical database-heavy web apps?
Read →
How do PHP Fibers work under the hood, and how do they differ from full async threads (Go Goroutines / Node.js Event Loop)?
Read →
How do you stream and parse a 50GB JSON/CSV export file in PHP without exceeding a 128MB memory limit?
Read →