创建性能计数器,以便跟踪分片映射管理器的性能Create performance counters to track performance of shard map manager

性能计数器用于跟踪数据相关路由操作的性能。Performance counters are used to track the performance of data dependent routing operations. 可在“弹性数据库: 分片管理”类别下的“性能监视器”中访问这些计数器。These counters are accessible in the Performance Monitor, under the "Elastic Database: Shard Management" category.

可以捕获分片映射管理器的性能,尤其是在使用数据依赖型路由时。You can capture the performance of a shard map manager, especially when using data dependent routing. 计数器是使用 Microsoft.Azure.SqlDatabase.ElasticScale.Client 类的方法创建的。Counters are created with methods of the Microsoft.Azure.SqlDatabase.ElasticScale.Client class.

有关最新版本: 请转到 Microsoft.Azure.SqlDatabase.ElasticScale.ClientFor the latest version: Go to Microsoft.Azure.SqlDatabase.ElasticScale.Client. 另请参阅升级应用以使用最新的弹性数据库客户端库See also Upgrade an app to use the latest elastic database client library.

先决条件Prerequisites

  • 若要创建性能类别和计数器,用户必须属于托管应用程序的计算机上的本地“管理员”组。To create the performance category and counters, the user must be a part of the local Administrators group on the machine hosting the application.
  • 若要创建性能计数器实例和更新计数器,用户必须是“管理员”或“性能监视器用户”组的成员。To create a performance counter instance and update the counters, the user must be a member of either the Administrators or Performance Monitor Users group.

创建性能类别和计数器Create performance category and counters

若要创建计数器,请调用 ShardMapManagementFactory 类的 CreatePerformanceCategoryAndCounters 方法。To create the counters, call the CreatePerformanceCategoryAndCounters method of the ShardMapManagementFactory class. 只有管理员才能执行该方法:Only an administrator can execute the method:

ShardMapManagerFactory.CreatePerformanceCategoryAndCounters()  

也可以使用PowerShell 脚本来执行该方法。You can also use this PowerShell script to execute the method. 该方法将创建以下性能计数器:The method creates the following performance counters:

  • 缓存的映射:分片映射缓存的映射数。Cached mappings: Number of mappings cached for the shard map.
  • DDR 操作数/秒:分片映射的数据相关路由操作速率。DDR operations/sec: Rate of data dependent routing operations for the shard map. OpenConnectionForKey() 的调用成功建立与目标分片的连接时,将更新此计数器。This counter is updated when a call to OpenConnectionForKey() results in a successful connection to the destination shard.
  • 映射查找缓存命中数/秒:分片映射中映射的成功缓存查找操作速率。Mapping lookup cache hits/sec: Rate of successful cache lookup operations for mappings in the shard map.
  • 映射查找缓存未命中数/秒:分片映射中映射的失败缓存查找操作速率。Mapping lookup cache misses/sec: Rate of failed cache lookup operations for mappings in the shard map.
  • 在缓存中添加或更新的映射数/秒:在缓存中为分片映射添加或更新映射的速率。Mappings added or updated in cache/sec: Rate at which mappings are being added or updated in cache for the shard map.
  • 从缓存中删除的映射数/秒:从缓存中删除分片映射的映射速率。Mappings removed from cache/sec: Rate at which mappings are being removed from cache for the shard map.

性能计数器是按进程为每个缓存分片映射创建的。Performance counters are created for each cached shard map per process.

注释Notes

以下事件会触发性能计数器创建:The following events trigger the creation of the performance counters:

对分片映射和映射执行的所有缓存操作将会更新性能计数器。The performance counters will be updated by all cache operations performed on the shard map and mappings. 使用 DeleteShardMap() 成功删除分片映射会导致删除性能计数器实例。Successful removal of the shard map using DeleteShardMap() results in deletion of the performance counters instance.

最佳实践Best practices

  • 只应在创建 ShardMapManager 对象之前创建性能类别和计数器一次。Creation of the performance category and counters should be performed only once before the creation of ShardMapManager object. 每次执行命令 CreatePerformanceCategoryAndCounters() 都会清除以前的计数器(丢失所有实例报告的数据),并创建新计数器。Every execution of the command CreatePerformanceCategoryAndCounters() clears the previous counters (losing data reported by all instances) and creates new ones.
  • 性能计数器实例是按进程创建的。Performance counter instances are created per process. 任何应用程序崩溃或从缓存中删除分片映射都会导致删除性能计数器实例。Any application crash or removal of a shard map from the cache will result in deletion of the performance counters instances.

另请参阅See also

弹性数据库功能概述Elastic Database features overview

其他资源Additional resources

尚未使用弹性数据库工具?Not using elastic database tools yet? 请查看入门指南Check out our Getting Started Guide.