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.
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.
-- 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%';
Too many connections waste memory; too few cause timeout errors.