Skip to main content
SRE

MySQL

MySQL too many connections

warning

Overview

What does this alert mean?

Connection count exceeds 80% of max_connections. New connections may be refused with 'Too many connections'.

Contributing factors

  • Connection leak — connections not returned to pool
  • Slow queries holding connections open longer than expected
  • max_connections set too low for the current workload

Affected components

  • Application services opening new connections
  • Connection pool managers

Expected action

Identify and kill long-running or idle connections. If the issue is persistent, increase max_connections or deploy a connection pooler.

Services

Metrics

Metric

mysql_global_status_threads_connected / mysql_global_variables_max_connections

Description & unit

Ratio of current connected threads to the configured maximum. Exported by mysqld_exporter.

Unit: ratio (0–1), alert threshold at 0.8

Threshold rationale

At 80% of max_connections, there is still headroom to investigate before connections are refused. At 100%, new connections fail immediately.

Normal behavior

Typically stays below 50% in healthy operation. Spikes during deploys or traffic bursts are normal but should recover within minutes.

Screenshots

Dashboard when connection ratio exceeds 80%
Dashboard when connection ratio exceeds 80%
Dashboard after connection count drops below threshold
Dashboard after connection count drops below threshold

Alert Behavior

Silencing

Silence during load tests or planned traffic migration events.

Expected frequency

Occasional — may fire during traffic spikes or after a deploy that causes connection leaks.

Severities

Severity guidance

Warning severity. Escalate to critical if connections reach 95%+ or new connection errors appear in application logs.

Impacted users

Users of any service that opens new database connections.

Things to check to determine severity

  • Are application error logs showing 'Too many connections'?
  • Was there a recent deploy?
  • Is a specific host or service responsible for the spike?

Verification

Prometheus query

mysql_global_status_threads_connected / mysql_global_variables_max_connections > 0.8

Dashboards

  • MySQL Connections — Fill in: dashboard URL

Log queries

  • Application connection errors — Fill in: log query URL

Troubleshooting

Steps

  1. 1Check current thread count: SHOW STATUS LIKE 'Threads_connected';
  2. 2Identify who is connected: SHOW PROCESSLIST;
  3. 3Find long-running queries: SELECT * FROM information_schema.processlist WHERE time > 30 ORDER BY time DESC;
  4. 4Kill a blocking query if safe: KILL QUERY ;
  5. 5Check configured maximum: SHOW VARIABLES LIKE 'max_connections';
  6. 6Increase temporarily if needed: SET GLOBAL max_connections = 500; — also update my.cnf for persistence

Useful commands

SHOW STATUS LIKE 'Threads_connected';SHOW PROCESSLIST;SELECT * FROM information_schema.processlist WHERE time > 30 ORDER BY time DESC;

Possible Resolutions

  • Connection leak after a deploy — rolling restart of the application cleared stale connections.

Dependencies

  • Application connection pools
  • ProxySQL or MySQL Router (if in use)

Escalation

Guidance

Escalate if connections exceed 95% or if application errors are visible to end users.

Slack channels

  • #database-oncall — Fill in: channel URL

Definitions

Alert rule

Fill in: link to the alert rule in _data/rules.yml on GitHub

Tuning notes

The 80% threshold is a ratio of the configured max_connections — it is self-normalizing. Only adjust if your application tolerates a higher saturation level.

Related Links

Template adapted from https://runbooks.gitlab.com/template-alert-playbook/