Testing the Performance of a Cloud Service
You can test the performance of a cloud service in the following ways:
By using diagnostics and performance counters, you can collect information about requests and connections, and you can review site statistics that show how the service performs from a customer perspective. To get started with Windows Azure Diagnostics, see Configuring Windows Azure Diagnostics. For more information, Overview of Creating and Using Performance Counters in a Windows Azure Application.
By using the Visual Studio profiler, you can get an in-depth analysis of the computational aspects of how the service runs. As this topic describes, you can use the profiler to measure performance as a service runs in Windows Azure. For information about how to use the profiler to measure performance as a service runs locally in a compute emulator, see Testing the Performance of a Windows Azure Cloud Service Locally in the Compute Emulator Using the Visual Studio Profiler.
This topic contains the following sections:
Use diagnostics when you want to collect the following kinds of information:
Statistics on web pages or services, such as requests and connections.
Statistics on roles, such as how often a role is restarted.
Overall information about memory usage, such as the percentage of time that the garbage collector takes or the memory set of a running role.
Use the Visual Studio profiler when you want to perform the following tasks:
Determine which functions take the most time.
Measure how much time each part of a computationally intensive program takes.
Compare detailed performance reports for two versions of a service.
Analyze memory allocation in more detail than the level of individual memory allocations.
Analyze concurrency problems in multithreaded code.
When you use the profiler, you can collect data when a cloud service runs locally or in Windows Azure.
You should collect profiling data locally when you want to perform the following tasks:
Test the performance of a part of a cloud service, such as the execution of specific worker role, that doesn’t require a realistic simulated load.
Test the performance of a cloud service in isolation, under controlled conditions.
Test the performance of a cloud service before you deploy it to Windows Azure.
Test the performance of a cloud service privately, without disturbing the existing deployments.
Test the performance of the service without incurring charges for running in Windows Azure.
You should collect profiling data in Windows Azure when you want to perform the following tasks:
Test the performance of a cloud service under a simulated or real load.
Use the instrumentation method of collecting profiling data, as this topic describes later.
Test the performance of the service in the same environment as when the service runs in production.
You typically simulate a load to test cloud services under normal or stress conditions. For more information, see Simulating Load on a Windows Azure Application.
When you publish your cloud service from Visual Studio, you can profile the service and specify the profiling settings that give you the information that you want. A profiling session is started for each instance of a role. For more information about how to publish your service from Visual Studio, see Publishing Cloud Services to Windows Azure from Visual Studio.
To understand more about performance profiling in Visual Studio, see Beginners Guide to Performance Profiling and Analyzing Application Performance by Using Profiling Tools.
You can enable either IntelliTrace or profiling when you publish your cloud service. You can't enable both.
You can use different collection methods for profiling, based on your performance issues:
This method collects application statistics that are useful for initial analysis of CPU utilization issues. CPU sampling is the suggested method for starting most performance investigations. There is a low impact on the application that you are profiling when you collect CPU sampling data.
This method collects detailed timing data that is useful for focused analysis and for analyzing input/output performance issues. The instrumentation method records each entry, exit, and function call of the functions in a module during a profiling run. This method is useful for gathering detailed timing information about a section of your code and for understanding the impact of input and output operations on application performance. This method is disabled for a computer running a 32-bit operating system. This option is available only when you run the cloud service in Windows Azure, not locally in the compute emulator.
.NET Memory Allocation
This method collects .NET Framework memory allocation data by using the sampling profiling method. The collected data includes the number and size of allocated objects.
This method collects resource contention data, and process and thread execution data that is useful in analyzing multi-threaded and multi-process applications. The concurrency method collects data for each event that blocks execution of your code, such as when a thread waits for locked access to an application resource to be freed. This method is useful for analyzing multi-threaded applications.
You can also enable Tier Interaction Profiling, which provides additional information about the execution times of synchronous ADO.NET calls in functions of multi-tiered applications that communicate with one or more databases. You can collect tier interaction data with any of the profiling methods. For more information about tier interaction profiling, see Tier Interactions View.
The following illustration shows how to configure your profiling settings from the Publish Windows Azure Application dialog box.
To enable the Enable profiling check box, you must have the profiler installed on the local computer that you are using to publish your cloud service. By default, the profiler is installed when you install Visual Studio Ultimate or Visual Studio Premium.
To configure profiling settings
In Solution Explorer, open the shortcut menu for your Windows Azure project, and then choose Publish.
For detailed steps about how to publish a cloud service, see Publishing a Cloud Service using the Windows Azure Tools.
To enable profiling, select the Enable profiling check box.
The Settings hyperlink is enabled.
To configure your profiling settings, choose the Settings hyperlink.
The Profiling Settings dialog box is displayed.
In the What method of profiling would you like to use option buttons, choose the type of profiling that you need.
To collect the tier interaction profiling data, select the Enable Tier Interaction Profiling check box.
To save the settings, choose the OK button.
When you publish this application, these settings are used to create the profiling session for each role.
A profiling session is created for each instance of a role in your cloud service. To view your profiling reports of each session from Visual Studio, you can view the Server Explorer window and then choose the Windows Azure Compute node to select an instance of a role. You can then view the profiling report as shown in the following illustration.
You must have Visual Studio Ultimate or Visual Studio Premium installed on the computer that you use to be able to view profiling reports for your cloud service.
To view profiling reports
To view the Server Explorer window in Visual Studio, on the menu bar choose View, Server Explorer.
Choose the Windows Azure Compute node, and then choose the Windows Azure deployment node for the cloud service that you selected to profile when you published from Visual Studio.
To view profiling reports for an instance, choose the role in the service, open the shortcut menu for a specific instance, and then choose View Profiling Report.
The report, a .vsp file, is now downloaded from Windows Azure, and the status of the download appears in the Windows Azure Activity Log. When the download completes, the profiling report appears in a tab in the editor for Visual Studio named <Role name>_<Instance Number>_<identifier>.vsp. Summary data for the report appears.
To display different views of the report, in the Current View list, choose the type of view that you want. For more information, see Profiling Tools Report Views.