MySQL show status - active or total connections?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
SHOW STATUS LIKE 'Threads_connected' shows active (currently open) connections. SHOW STATUS LIKE 'Connections' shows the total cumulative count of connection attempts since the server started. These are two different metrics, and confusing them is one of the most common MySQL monitoring mistakes. If you need to know "how many clients are connected right now," the answer is Threads_connected. If you need "how many connections has this server handled since last restart," the answer is Connections.
The Key Status Variables
MySQL exposes several connection-related status variables. Here are the ones that matter most:
| Variable | What It Measures | Resets On Restart |
Connections | Total connection attempts (successful + failed) since server start | Yes |
Threads_connected | Currently open connections right now | N/A (live gauge) |
Threads_running | Connections actively executing a query right now | N/A (live gauge) |
Max_used_connections | High-water mark for simultaneous connections since server start | Yes |
Aborted_connects | Failed connection attempts (bad password, too many connections, etc.) | Yes |
Aborted_clients | Connections that were closed without proper logout | Yes |
The distinction between Threads_connected and Threads_running is important. A connection can be open but idle, waiting for the application to send a query. Threads_connected counts all open connections (active + idle). Threads_running counts only those actively executing a statement.
Checking Current Connections
How Many Clients Are Connected Now
This tells you 42 client connections are currently open. Some may be actively querying, others may be idle.
How Many Are Actively Running Queries
Out of 42 connected clients, only 5 are executing a query at this moment. The other 37 are idle but holding open connections.
What Each Connection Is Doing
Or for the full query text:
This lists every connected thread with its state, current query, and how long it has been in that state. It is the best way to identify long-running queries, sleeping connections, and locked threads.
For a more queryable format:
This filters out sleeping (idle) connections and sorts by duration, showing the longest-running active queries first.
Connection Limits and Capacity
Check Your Maximum Allowed Connections
The default is 151. In production, this is almost always too low.
Check the High-Water Mark
This tells you the peak number of simultaneous connections since the last server restart. If this value is close to max_connections, you are at risk of hitting the connection limit.
Connection Utilization Percentage
A useful operational metric is how close you are to the limit:
If utilization is consistently above 80%, increase max_connections or implement connection pooling.
Configuring max_connections
At Runtime (No Restart Required)
This takes effect immediately but reverts on server restart.
In the Configuration File (Persistent)
After editing, restart MySQL or reload the configuration.
Sizing Considerations
Each connection consumes memory. The rough formula is:
With default settings, each connection uses roughly 1-10 MB depending on the query. Setting max_connections = 10000 on a server with 4 GB of RAM will eventually cause out-of-memory issues if those connections are all active.
Connection Pooling
Instead of raising max_connections indefinitely, use a connection pooler. The application maintains a pool of reusable connections, which keeps the total count manageable.
Example: HikariCP (Java)
Example: Connection Pool in Python
Monitoring Connections Over Time
For ongoing monitoring, record these values periodically:
Feed this into Grafana, Datadog, or any time-series monitoring system to track connection trends and catch issues before they become outages.
Common Pitfalls
Confusing Connections with Threads_connected. Connections is a cumulative counter since server start. It increases monotonically. Threads_connected is a live gauge of currently open connections. If someone asks "how many connections do we have," they almost certainly mean Threads_connected.
Setting max_connections too high without considering memory. Each connection reserves memory buffers. A server with 1000 active connections and default buffer sizes can consume several gigabytes of RAM for connections alone, leaving insufficient memory for the InnoDB buffer pool.
Not monitoring Aborted_connects. A high rate of aborted connections often indicates authentication failures, connection storms from misbehaving applications, or clients being rejected because max_connections was reached. This metric is easy to overlook but operationally important.
Ignoring idle connections. Applications that open connections without closing them inflate Threads_connected without doing useful work. Use wait_timeout to automatically close idle connections after a configurable period (default is 28800 seconds, which is 8 hours).
Using SHOW PROCESSLIST instead of information_schema.PROCESSLIST for programmatic access. SHOW PROCESSLIST truncates query text to 100 characters and is harder to filter. The information_schema version gives you the full query and can be filtered with standard SQL WHERE clauses.
Summary
Threads_connected is the metric for currently open connections. Connections is the total cumulative count since server start. Threads_running shows how many of those connections are actively executing queries. Monitor Max_used_connections relative to max_connections to detect capacity issues before they cause connection rejections. Use connection pooling to keep the connection count manageable, and configure wait_timeout to clean up idle connections automatically. For production monitoring, track these values over time rather than checking them ad hoc.
Related reading

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.