Create and Use Performance Counters in a Windows Azure Application
Updated: August 24, 2011
Just as with Windows Server, you can use performance counters in a Windows Azure application to collect data that can help determine system bottlenecks and fine-tune system and application performance. Web roles, worker roles, and VM roles can dynamically configure performance counters collected by the Windows Azure diagnostic monitor, and create and use custom performance counters for application-specific monitoring and management. Performance counter data can be examined directly on the application host with the Performance Monitor tool accessed using Remote Desktop, with System Center Operations Manager using the Windows Azure Management Pack, or with other monitoring tools that access the diagnostic data transferred to Windows Azure storage. See Store and View Diagnostic Data in Windows Azure Storage for more information.
Performance counters are not enabled by default in the diagnostic monitor. Your application or a startup task must modify the default diagnostic monitor configuration to include the specific performance counters that you wish to monitor for each role instance if you need performance counter data.
Windows Azure provides a subset of the performance counters available for Windows Server 2008, IIS and the ASP.NET stack. The following table lists some of the performance counters of particular interest for Windows Azure applications.
| Counter Category: Object (Instance) | Counter Name | Reference |
|---|---|---|
|
.NET CLR Exceptions(_Global_) |
# Exceps Thrown / sec |
|
|
.NET CLR Memory(_Global_) |
% Time in GC |
|
|
ASP.NET |
Application Restarts |
|
|
ASP.NET |
Request Execution Time |
|
|
ASP.NET |
Requests Disconnected |
|
|
ASP.NET |
Worker Process Restarts |
|
|
ASP.NET Applications(__Total__) |
Requests Total |
|
|
ASP.NET Applications(__Total__) |
Requests/Sec |
|
|
ASP.NET v4.0.30319 |
Request Execution Time |
|
|
ASP.NET v4.0.30319 |
Request Wait Time |
|
|
ASP.NET v4.0.30319 |
Requests Current |
|
|
ASP.NET v4.0.30319 |
Requests Queued |
|
|
ASP.NET v4.0.30319 |
Requests Rejected |
|
|
Memory |
Available MBytes |
|
|
Memory |
Committed Bytes |
|
|
Processor(_Total) |
% Processor Time |
|
|
TCPv4 |
Connection Failures |
|
|
TCPv4 |
Connections Established |
|
|
TCPv4 |
Connections Reset |
|
|
TCPv4 |
Segments Sent/sec |
|
|
Network Interface(*) |
Bytes Received/sec |
|
|
Network Interface(*) |
Bytes Sent/sec |
|
|
Network Interface(Microsoft Virtual Machine Bus Network Adapter _2) |
Bytes Received/sec |
|
|
Network Interface(Microsoft Virtual Machine Bus Network Adapter _2) |
Bytes Sent/sec |
|
|
Network Interface(Microsoft Virtual Machine Bus Network Adapter _2) |
Bytes Total/sec |
Windows Azure has support for custom performance counter creation and modification for web roles and worker roles. Custom performance counters may be used to track and monitor application-specific behavior. Custom performance counter categories and counter specifiers can be created or deleted in a startup task, web role, or worker role with elevated permissions.
Note |
|---|
Code that makes changes to custom performance counters must have elevated permissions to run. If the code is in a web role or worker role, the role must include the tag <Runtime executionContext="elevated" /> in the ServiceDefinition.csdef file for the role to initialize properly. |
Custom performance counters may be enabled and have their data transferred to Windows Azure storage with standard performance counters using the diagnostic monitor.
The standard performance counter data is generated by the Windows Azure processes. Custom performance counter data must be created by your web role or worker role application. See Performance Counter Types for information on the types of data that can be stored in custom performance counters. See PerformanceCounters Sample for an example that creates and sets custom performance counter data in a web role.
Performance counter data is cached in Windows Azure with other diagnostic information. This data is available for remote monitoring while the role instance is running using remote desktop access to view tools such as Performance Monitor. To persist the data outside of the role instance, the diagnostic monitor must transfer the data to Windows Azure storage. The size limit of the cached performance counter data can be configured in the diagnostic monitor, or it may be configured to be part of a shared limit for all the diagnostic data. For more information about setting the buffer size, see OverallQuotaInMB and DirectoriesBufferConfiguration. See Store and View Diagnostic Data in Windows Azure Storage for an overview of setting up the diagnostic monitor to transfer data to a storage account.
Each configured performance counter instance is recorded at a specified sampling rate, and the sampled data is transferred to the storage account either by a scheduled transfer request or an on-demand transfer request. Automatic transfers may be scheduled as often as once per minute. Performance counter data transferred by the diagnostic monitor is stored in a table, WADPerformanceCountersTable, in the storage account. This table may be accessed and queried with standard Windows Azure storage API methods. See Windows Azure PerformanceCounters Sample for an example of querying and displaying performance counter data from the WADPerformanceCountersTable table.
Note |
|---|
| Depending on the diagnostic monitor transfer frequency and queue latency, the most recent performance counter data in the storage account may be several minutes out of date. |
See Also
Note