监视 Azure Database for MySQL - 单一服务器的最佳做法Best practices for monitoring Azure Database for MySQL -Single server

备注

将要查看的是 Azure Database for MySQL 的新服务。You are viewing the new service of Azure Database for MySQL. 若要查看经典 MySQL Database for Azure 的文档,请访问此页To view the documentation for classic MySQL Database for Azure, please visit this page.

了解可用于监视数据库操作并确保性能不会随着数据大小的增长而降低的最佳做法。Learn about the best practices that can be used to monitor your database operations and ensure that the performance is not compromised as data size grows. 在向平台添加新功能时,我们将继续优化本部分中详述的最佳做法。As we add new capabilities to the platform, we will continue refine the best practices detailed in this section.

当前监视工具包的布局Layout of the current monitoring toolkit

Azure Database for MySQL 提供所需的工具和方法,用于轻松监视使用情况、添加或删除资源(例如 CPU、内存或 I/O)、排查潜在问题并提高数据库的性能。Azure Database for MySQL provides tools and methods you can use to monitor usage easily, add, or remove resources (such as CPU, memory, or I/O), troubleshoot potential problems, and help improve the performance of a database. 可以定期监视性能指标,以查看各种时间范围的平均值、最大值和最小值。You can monitor performance metrics on a regular basis to see the average, maximum, and minimum values for a variety of time ranges.

可以为指标阈值设置警报,以便你了解服务器是否已达到这些限制并采取适当措施。You can set up alerts for a metric threshold, so you are informed if the server has reached those limits and take appropriate actions.

监视数据库服务器,以确保分配给数据库的资源能够处理应用程序工作负载。Monitor the database server to make sure that the resources assigned to the database can handle the application workload. 如果数据库即将达到资源限制,请考虑:If the database is hitting resource limits, consider: * 识别资源消耗量最大的查询并对其进行优化。Identifying and optimizing the top resource-consuming queries. * 通过升级服务层级来添加更多的资源。Adding more resources by upgrading the service tier.

CPU 使用率CPU utilization

监视 CPU 使用率以及数据库是否耗尽 CPU 资源。Monitor CPU usage and if the database is exhausting CPU resources. 如果 CPU 使用率为 90% 或更多,则应该通过增加 vCore 的数量或缩放到下一个定价层来纵向扩展计算。If CPU usage is 90% or more than you should scale up your compute by increasing the number of vCores or scale to next pricing tier. 在纵向扩展或纵向缩减 CPU 时,请确保吞吐量或并发符合预期。Make sure that the throughput or concurrency is as expected as you scale up/down the CPU.

内存Memory

数据库服务器的可用内存量与 vCore 数目成正比。The amount of memory available for the database server is proportional to the number of vCores. 确保内存对于工作负荷而言足够。Make sure the memory is enough for the workload. 对应用程序进行负载测试以验证内存是否足以支持读写操作。Load test your application to verify the memory is sufficient for read and write operations. 如果数据库内存消耗经常超过定义的阈值,则表示你应该通过增加 vCore 数目或扩展到更高的性能层来升级实例。If the database memory consumption frequently grows beyond a defined threshold, this indicates that you should upgrade your instance by increasing vCores or higher performance tier. 使用查询存储查询性能建议来确定持续时间最长、执行次数最多的查询。Use Query Store, Query Performance Recommendations to identify queries with the longest duration, most executed. 探索优化机会。Explore opportunities to optimize.

存储Storage

为 MySQL 服务器预配的存储量决定服务器的 IOP。The amount of storage provisioned for the MySQL server determines the IOPs for your server. 服务使用的存储包括数据库文件、事务日志、服务器日志和备份快照。The storage used by the service includes the database files, transaction logs, the server logs and backup snapshots. 确保消耗的磁盘空间不会经常超过预配磁盘空间总数的 85%。Ensure that the consumed disk space does not constantly exceed above 85 percent of the total provisioned disk space. 如果是这种情况,则需要从数据库服务器中删除或存档数据以释放一些空间。If that is the case, you need to delete or archive data from the database server to free up some space.

流量Network traffic

网络接收吞吐量、网络传输吞吐量 - 与 MySQL 实例之间的网络流量速率(以兆字节/秒为单位)。Network Receive Throughput, Network Transmit Throughput – The rate of network traffic to and from the MySQL instance in megabytes per second. 你需要评估服务器的吞吐量要求,如果吞吐量低于预期,则需要持续监视流量。You need to evaluate the throughput requirement for server and constantly monitor the traffic if throughput is lower than expected.

数据库连接Database connections

数据库连接 - 连接到 Azure Database for MySQL 的客户端会话数应与所选 SKU 大小的连接限制对齐。Database Connections – The number of client sessions that are connected to the Azure Database for MySQL should be aligned with the connection limits for the selected SKU size.

后续步骤Next steps