Date
January 25, 2024

Connections Are Expensive

Each MySQL connection consumes memory for its thread stack, session buffers, and sort/join buffers. At hundreds or thousands of concurrent connections, this overhead alone can exhaust server memory and trigger OOM kills, even if the queries themselves are lightweight.

ProxySQL vs Application-Level Pooling

Application-level connection pools (HikariCP, SQLAlchemy pool, etc.) reduce connection overhead within a single application. ProxySQL sits between your applications and MySQL, providing connection multiplexing, query routing, query caching, and read/write splitting across your entire infrastructure.

Right-Sizing Your Pool

The optimal pool size is almost always smaller than developers expect. A database server with 16 CPU cores rarely benefits from more than 30-50 active connections. Beyond that, you get diminishing returns from context switching and lock contention.

The formula is straightforward: connections = (core_count * 2) + effective_spindle_count. For SSD-backed systems, start there and adjust based on monitoring data, not guesswork.

Sign up to our newsletter and get tips and tricks inbox

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

We promise. No spam. Only high quality content, exciting news and useful tips and tricks from the team.