How to Monitor MySQL Database Performance

DigitalOcean Managed Databases include metrics visualizations so you can monitor performance and health of your database cluster. There are two kinds of metrics:

  • Cluster metrics monitor the performance of the nodes in a database cluster. Cluster metrics cover primary and standby nodes; metrics for each read-only node are displayed independently. This data can help guide capacity planning and optimization. You can also set up alerting on cluster metrics.

  • Database metrics monitor the performance of the database itself. This data can help assess the health of the database, pinpoint performance bottlenecks, and identify unusual use patterns that may indicate an application bug or security breach.

There are two groups of MySQL metrics: master server metrics, which are metrics on all databases in the cluster, and database metrics, which are metrics on individual database performance.

View MySQL Metrics

To view performance metrics for a MySQL database cluster, click the name of the database to go to its Overview page, then click the Insights tab.

The Insights tab of a Managed Database cluster

The Select object drop-down menu lists the cluster itself and all of the databases in the cluster. Choose the database to view its metrics.

In the Select Period drop-down menu, you can choose a time frame for the x-axis of the graphs, ranging from 1 hour to 30 days. Each line in the graphs will display about 300 data points.

By default, the summary to the right shows the most recent metrics values. If you hover over a different time in a graph, the summary will display the values from that time instead.

Note
You may notice gaps in your metrics data from outages, platform maintenance, or a database failover or migration. You can check DigitalOcean’s status page for outages, review the cluster maintenance window, visit the cluster’s Settings > Logs & Queries page to look for failovers and migrations.

If you recently provisioned the cluster or changed its configuration, it may take a few minutes for the metrics data to finish processing before you see it on the Insights page.

MySQL Master Server Metrics Details

MySQL-specific master server metrics include:

  • Connection status: the number of threads created, connected, and running in relation to the connection limit.

  • Index vs. sequential reads: The reads using an index as a proportion of the total reads across all databases on the server.

  • Operations throughput: Throughput of fetch, insert, update and delete operations across all databases on the server.

Master server metrics are displayed in the same view as cluster performance metrics.

Connection Status

The connection status plot displays the number of client threads, i.e. processes, grouped by the following statuses:

  • Threads connected to the server
  • Threads created
  • Currently executing threads

This plot also displays the connection limit as a dotted line.

MySQL connection status plot

If the number of connected threads regularly approaches or exceeds the connection limit, consider implementing client-side connection pooling or upgrading your database plan to increase your connection limit.

Index vs. Sequential Reads

The index vs. sequential reads plot presents the proportion of reads that use an index over the total number of reads across all databases (schemas) on the master server.  

MySQL index vs. sequential reads plot

In general, queries across large tables can be optimized through the use of an index. Use the MySQL query statistics on the Logs & Queries tab and the EXPLAIN statement to identify slow queries that may benefit from the addition of an index.

Operations throughput

The operations throughput plot displays the rate of fetch, insert, update and delete operations per second across all databases (schemas) on the master server.

MySQL operations throughput plot

You can compare this plot with node performance metrics to identify potential resource constraints. For more insights, look at the individual database-level metrics and the query statistics on the Logs & Queries page.

MySQL Database Metrics

MySQL databases have the following metrics:

  • Throughput: row-based throughput of fetches, inserts, updates, and deletes
  • Latency: latency of fetches, inserts, updates, and deletes

Throughput

The throughput plot shows the rate of fetches, inserts, updates, and deletes in rows per second.

MySQL throughput plot

If you observe bottlenecks, look for slow queries in the query statistics on the Logs & Queries page, then use the EXPLAIN statement to explore opportunities for query optimization.

Latency

The latency plot shows the average time, in seconds, of fetches, inserts, updates, and deletes.

MySQL latency plot

If you observe bottlenecks, use the EXPLAIN statement for optimization recommendations.