Profiling Azure Cloud Services

Profiling

Profiling is nothing but a process of measuring the performance analysis of an application. It is usually done to ensure that the application is stable enough and can sustain heavy traffic.

Visual Studio provides us various tools to do it by gathering the performance data from the application that also helps in the troubleshooting issues.

Once the profiling wizard is run, it establishes the performance session and collects the sampling data, then generates report files that can be opened and analyzed in Visual Studio.

The profiling reports can help us to:

    • Determine the longest running methods within the application.
    • Measure the execution time of each method in the call stack.
    • Evaluate memory allocation.
    • Analyze concurrency issues (usually for multi-threaded code).
How to do profiling in Azure cloud services
So having said that the profiling is a wonderful feature, how can I use it if I have already deployed my cloud services on Azure?

Well, thanks to the Azure SDK, it now allows us to create and deploy profiling builds on cloud services. The Visual Studio Server Explorer helps in downloading these profile reports for further analysis.
All we need to do is to deploy the solution package to the cloud service using Visual Studio with certain configurations. After deployment, a performance session will be started on each role instance of the service.

So let's start by launching the deployment wizard as in the following:
 
Sign in with your account, once you are done, click Next.

setting

In the common settings tab, make sure you have specified the correct cloud service name, deployment slot and build as well as service configuration.

In the advanced settings tab, select the name of the Azure storage account that you have associated with your cloud service, or you can choose to create a new one.

Now the checkbox "enable profiling" needs to be checked. Once you check it, a profiling settings window will be shown where you must specify the performance parameters you want to measure with this profiling build.

cpu sempling

Select one of the settings and click OK.

Click Next in the main wizard and it will show up a summary page containing all the settings that you have set in the previous procedure. Make sure you have profiling enabled and click on publish.

The magic

Some of you who are familiar with the normal deployment process must be wondering by now that the entire process looked the same except for a check of a checkbox, so what does Visual Studio do that is special behind the scenes that deploys a special build?

Here is the answer.

Visual Studio adds some settings to your service definition and service configuration files.

In csdef:
  1. <InternalEndpoint name="Microsoft.WindowsAzure.Plugins.Caching.cacheArbitrationPort" protocol="tcp" />  
  2. <InternalEndpoint name="Microsoft.WindowsAzure.Plugins.Caching.cacheClusterPort" protocol="tcp" />  
  3. <InternalEndpoint name="Microsoft.WindowsAzure.Plugins.Caching.cacheReplicationPort" protocol="tcp" />  
  4. <InternalEndpoint name="Microsoft.WindowsAzure.Plugins.Caching.cacheServicePortInternal" protocol="tcp" />  
  5. <InternalEndpoint name="Microsoft.WindowsAzure.Plugins.Caching.cacheSocketPort" protocol="tcp" />  
In cscfg:
  1. <Setting name="Profiling.ProfilingConnectionString" value="YourStorageAccount" />  
  2. <Setting name="CloudToolsDiagnosticAgentVersion" value="2.2" />  
And the size of the deployment package is increased by a significant amount, why? Because Visual Studio adds the profiler to the package.

View profile reports

(Note: You must have Visual Studio Premium or Visual Studio Ultimate installed on the computer and that you can use for this to be able to view profiling reports for your cloud service.)

Once you enable the profiling and deploy the cloud service, Visual Studio Server Explorer helps you in getting the report out of your profiling build with just a single click and you are set to analyze the reports.

Open the Server Explorer and select the Azure node.

Expand the cloud services node and select your cloud service.

Select and expand the deployment slot on which you deployed the profiling build and you will see all the instances of your roles.

Select role instance, right-click on it and select view profiling report. A .vsp file will be downloaded from Azure that will be shown in the Azure activity log.

Up Next
    Ebook Download
    View all
    Learn
    View all