SyntaxStudy
Sign Up
MySQL Intermediate 4 min read

Connection Pooling

Connection Pooling

Opening a new database connection is expensive. Connection pooling reuses existing connections. Configure max_connections in MySQL and use a pool in your application layer.

Example
-- Check current connections
SHOW STATUS LIKE 'Threads_connected';
SHOW STATUS LIKE 'Max_used_connections';

-- Set max connections (my.cnf)
-- max_connections = 200

-- Show wait events
SHOW STATUS LIKE 'Connection_errors%';
Pro Tip

Too many connections waste memory; too few cause timeout errors.