TheRobotLearns Platform · ProxySQL: from first install to production
Hostgroup Connection-Pool Statistics and Reset Windows
Learning objectives
- Query hostgroup_connection_pool stats for MySQL or PostgreSQL through ProxySQL Admin.
- Interpret acquisitions_total, waits_total, wait_time_us_total, and waiters without assuming TCP/statement/request.
- Compute per-second counter deltas across observations, treating waiters as a current gauge.
- Correlate hostgroup waits with per-server pool errors, usage, and Queries in connection_pool tables.
- Reset cautiously, knowing any read starts a new Admin window, not only shown rows.
- Use proxysql_connpool hostgroup/protocol labels, counter rates, and waiters gauge despite Admin resets.
When requests wait for connections
You see slow application requests, but their SQL runs quickly on an available database connection. Hostgroup connection-pool statistics show whether requests wait for a backend connection before the database can execute their work.
These tables are available in ProxySQL 3.1.12 and 4.0.12 for MySQL and PostgreSQL. They are not available in ProxySQL 3.0. No additional collection setting is required. You query them through ProxySQL Admin, normally on port 6032.
A hostgroup is a destination ID for routed traffic. One server can appear in several hostgroups, and one hostgroup can contain several servers.
For MySQL traffic routed to hostgroup 20, query stats_mysql_hostgroup_connection_pool. For PostgreSQL traffic, query stats_pgsql_hostgroup_connection_pool.
Replace 20 with the actual destination hostgroup before you compare routing and backend configuration. The MySQL query shows hostgroup, acquisitions_total, waits_total, wait_time_us_total, and waiters.
Routing rules and active transactions can affect that destination, so check the group serving the request.
Takeaway: Query the hostgroup serving the request in the MySQL or PostgreSQL connection-pool statistics.
Read counters without guessing
You read acquisitions_total, waits_total, wait_time_us_total, and waiters from the hostgroup table. The first three are counters, so you compare them over time. waiters is a gauge, so you read its current value.
acquisitions_total records successful backend connection acquisitions. waits_total records logical waits begun after an acquisition could not succeed. Repeated retries of one wait do not create new waits. wait_time_us_total records the duration of finished waits in microseconds.
You divide wait_time_us_total by 1,000,000 to get seconds. waiters records requests currently waiting for a connection. An acquisition is not necessarily a new TCP connection, a SQL statement, or an application request. A backend retained for a transaction can execute several statements without another acquisition.
A wait also does not prove the configured connection limit is too low. Server availability, routing constraints, and occupied connections can all affect acquisition. For hostgroup 20, these columns show pressure on a group. They do not show one physical database, because one server can appear in several groups.
Takeaway: Compare counters over time, and read waiters as the current value.
Compare samples and pool views
You save a hostgroup result with a timestamp, then repeat the same query during the incident, for example after 60 seconds. For the same hostgroup, subtract the first counter values from the second. The change in acquisitions_total divided by elapsed seconds shows the successful acquisition rate. The change in waits_total divided by elapsed seconds shows the rate of new logical waits.
The change in wait_time_us_total divided by 1,000,000 shows additional recorded wait time, in seconds. Keep waiters alongside those changes. Do not subtract it to count waits. A queue can grow and empty repeatedly between samples.
Wait time is recorded when a wait finishes. Concurrent waits can accumulate more than one second of wait time per second of wall-clock time. Compare the hostgroup queue with stats_mysql_connection_pool for hostgroup 20.
Its selected columns include srv_host, srv_port, status, ConnUsed, ConnFree, MaxConnUsed, ConnERR, and Queries. Queries also appears there. For PostgreSQL, use stats_pgsql_connection_pool, and these selected columns have the same names.
ConnUsed and ConnFree describe current pool usage. MaxConnUsed records peak usage, and ConnERR accumulates connection failures.
Takeaway: Subtract counter deltas over elapsed seconds, and use ConnUsed, ConnFree, and ConnERR for per-server pressure.
Read reset windows carefully
You query a reset table during an incident, but the live queue does not stop. The corresponding reset tables are stats_mysql_hostgroup_connection_pool_reset and stats_pgsql_hostgroup_connection_pool_reset. For MySQL, SELECT * FROM stats_mysql_hostgroup_connection_pool_reset returns the window, and the next Admin window starts. Reading either table starts a new Admin window for that protocol's hostgroups.
The normal tables do not clear counters. Reading a reset table does not clear live waiters. Filtering a reset query to one hostgroup does not make the reset exclusive to that row. Prefer the normal tables for shared monitoring.
If another observer resets the window, or ProxySQL restarts, discard the old baseline and begin a new interval instead of reporting negative activity. Prometheus exposes proxysql_connpool_acquisitions_total, proxysql_connpool_waits_total, proxysql_connpool_wait_time_seconds_total, and proxysql_connpool_waiters. The metrics carry hostgroup and protocol labels, and protocol values are mysql and pgsql.
Use rates for counters and the current gauge for waiters. Prometheus wait time is in seconds, whereas the Admin table uses microseconds. Reading an Admin reset table does not reset Prometheus counters. These counters do not measure database lock waits, network latency, or waiting inside the application's own connection pool.
Takeaway: Admin resets start a new window; Prometheus keeps rates, labels, and current waiters.
Observe hostgroup pool pressure
SELECT hostgroup, acquisitions_total, waits_total,
wait_time_us_total, waiters
FROM stats_mysql_hostgroup_connection_pool
WHERE hostgroup=20;
SELECT hostgroup, srv_host, srv_port, status,
ConnUsed, ConnFree, MaxConnUsed, ConnERR, Queries
FROM stats_mysql_connection_pool
WHERE hostgroup=20
ORDER BY srv_host, srv_port;
SELECT * FROM stats_mysql_hostgroup_connection_pool_reset;The first statement returns hostgroup 20 acquisitions_total, waits_total, wait_time_us_total, and waiters from stats_mysql_hostgroup_connection_pool. The second statement returns hostgroup 20 rows from stats_mysql_connection_pool with ConnUsed, ConnFree, MaxConnUsed, ConnERR, and Queries, ordered by srv_host and srv_port. The third statement reads stats_mysql_hostgroup_connection_pool_reset, so you get the current Admin window and a new window starts. It does not clear live waiters. For PostgreSQL traffic, replace the MySQL tables with stats_pgsql_hostgroup_connection_pool and stats_pgsql_connection_pool, and use stats_pgsql_hostgroup_connection_pool_reset for the reset table.
Sources
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
- Hostgroup connection-pool statistics
Do more with an account
- Graded quizzes is available on your account.
- Saving your progress is available on your account.
- Hands-on labs is available on your account.
- AI tutoring is available on your account.