traffic performance

Connection Multiplexing

Handle 100k+ client connections with just a few hundred backend connections.

Architectural Value

Multiplexing solves the "C10K problem" for databases. By decoupling client connections from server connections, you can scale your application tier independently of your database capacity. Never let misconfigured microservices impact your overall database usage for other applications.

Key Capabilities

  • Reduced Backend Load: Drastically lowers memory usage on MySQL/PostgreSQL servers.
  • Latency Reduction: Eliminates the overhead of constant connection setup/teardown.
  • Transparent Scaling: Your application sees unlimited connections while your DB stays cool.

Implementation

Learn how to configure this feature in your ProxySQL instance.

View Technical Docs

Architectural Review

Not sure if this fits your current stack? Our experts can help.

Schedule a Call →

The Problem

MySQL and PostgreSQL weren’t built for modern connection demands, though for different reasons. MySQL pays a thread-per-connection cost, typically 256KB to several megabytes per connection. PostgreSQL takes a different approach entirely: each connection forks a dedicated OS process, carrying independent memory buffers and authentication state that can reach tens of megabytes per connection at scale. This was a reasonable tradeoff when applications were monolithic and connections were few. It becomes a crisis when microservices, serverless functions, and Kubernetes-scaled replicas each arrive with their own connection pools.

The failure mode is predictable: max_connections is hit, new connections are rejected, and your application surfaces errors that look like database failures but are fundamentally infrastructure failures. The data is fine. The database engine is healthy. The bottleneck is the connection layer itself.

Why Application-Side Pooling Isn’t Enough

Local connection pools are scoped to each process. In a distributed system with hundreds of replicas, each holding connections open speculatively, aggregate connection count at the database grows with your fleet size — not with actual query concurrency. Two hundred replicas with pools of ten connections each presents 2,000 connections to your database, even if peak concurrent execution at any moment is fifty.

Solving this requires a proxy with full protocol awareness sitting between your application tier and your database.

The ProxySQL Approach

ProxySQL parses the MySQL and PostgreSQL wire protocol completely, which allows it to make precise decisions about when a backend connection is safe to reassign. When a query completes and the connection is in a clean state — no open transaction, no session variables, no active locks — the backend connection returns immediately to the shared pool. The client remains connected to ProxySQL, but no longer holds a backend connection.

State safety is handled automatically. ProxySQL tracks open transactions, session variables, temporary tables, and locks. Any condition that creates session-bound state disables multiplexing for that pair until it resolves. Multiplexing is always correct by default, and connection sharing is maximized wherever it is safe.

The Result

Read-heavy workloads typically achieve multiplexing ratios of 50:1 to 200:1. Ten thousand client connections sustained by one hundred to two hundred backend connections is a realistic production outcome. Memory pressure on your database drops sharply, connection establishment latency is eliminated from your query path, and your application tier can scale horizontally without the database connection layer becoming the point of failure.