dcsimg
September 29, 2016
Hot Topics:

Tips for Debugging Cloud Applications like a Pro

  • June 10, 2015
  • By Vipul Patel
  • Send Email »
  • More Articles »

Introduction

As an increasing number of applications shift towards the cloud, it is imperative that developers master the techniques that enable them to effectively debug cloud applications. In this article, I am sharing a few tips that can help developers debug cloud applications hosted in Azure (both Infrastructure as a Service as well as Platform as a Service cases) with the same ease that they debug local desktop applications.

Here are certain scenarios that developers frequently encounter:

  • Issues with an application not running on Azure but working fine with an emulator.
  • Issues with roles and startup. For example, the role remains in a pending state forever.
  • Issues with service performance. For example, certain tasks taking an extremely long time or the service not scaling to handle "foo" number of concurrent requests.
  • Logical issues in application. For example, when the application logic isn't very clear and the application is poorly designed/implemented and it is hard to find the root cause.
  • Issues with data collection and data viewing when instrumentation is turned on and you are getting large amounts of data.

Let us take these issues one by one.

Applications Working Fine on an Emulator but not on the Azure Cloud

There are many things that can be done to avoid such issues:

  • One of the most subtle ones shows up as a warning in Visual Studio's Build window, warning developers that they are deploying an assembly that is not on Azure. This appears when they publish the application and the Activity window pops up; hence, it is very easy to miss. Developers should always look for any warnings during build time and publishing time and fix them.
  • Other things that can be done are to enabling logging and tracing and using IntelliTrace to get details of what the application is doing.

Issues with Startup and Roles

To debug startup issues, you can do the following:

  • Write custom logic that gets executed on startup.
  • Enable logging/tracing and IntelliTrace.
  • Even sync the remote desktop to the host machine.

Issues with Service Performance

To debug performance issues, the best strategies include:

  • Enable logging/tracking using Windows Azure Diagnostics
  • Use Visual Studio profiler
  • Use Application insights

Issues with Application Logic

To debug issues with application logic or unknown root causes, consider the following:

  • Enable logging/tracking using Windows Azure Diagnostics
  • Remote the desktop to the host machine
  • Use Application Insights

As you can see, the debugging strategies for most of the issues referenced in the preceding list include logging/tracing. We will now explore how to use Windows Azure Diagnostics to enable rich logging/tracing for your application/service.

Windows Azure Diagnostics

Windows Azure Diagnostics (WAD) is a framework that can be used to implement application logging and tracing. It is a free diagnostics agent that can be used for PaaS and IaaS VMs.

Here are a few features available as part of Windows Azure diagnostics:

  • Developers can use tracing/logging classes in the System.Diagnostics namespace in their applications. They can even use Event Tracing for Windows. The Azure Diagnostics agent will also capture ETW events.
  • WAD also monitors Windows Event logs on the guest OS.
  • WAD can capture performance counts, crash dumps, custom logs, and the Azure infrastructure logs for your IaaS and PaaS VMs.
  • WAD also supports writing data to local and cloud storage. Developers can see how the tracing will work.

The Windows Azure Diagnostics agent operates like an extension and it can work locally with an emulator. It can be applied at any time once the role is ready.

Windows Azure Diagnostics can be configured by using the .wadcfgx file and can be updated any time on a running service.

Startup Issues

To avoid startup issues like what we discussed earlier, we can do tweak the startup task to help with moving log files:

    1. Add a local storage element to the LocalResource element in the .csdef file.
<LocalStorage name="MyInstallLogs" sizeInMB="10"
   cleanOnRoleRecycle="false" />
  1. Create an environment variable to your startup task.
    <Environment>
       <Variable name="PathToInstallLogs">
          <RoleInstanceValue xpath="/RoleEnvironment/
             CurrentInstance/LocalResources/
             LocalResources[@name='MyInstallLogs']/
             @path" />
       </Variable>
    </Environment>
    
  2. Update the install script to write the logs to the directory specified above.
  3. Instruct Azure Diagnostics to transfer the logs by adding the local resource to the directory configuration of the Azure diagnostics config (.wadcfgx).

Role Recycling Issues

If you are seeing role recycling issues, you can begin by checking if there are any build warnings during publishing time.

You also should use Remote Desktop on the machine and check:

  • Windows Event logs
  • Archived WaHostBootstrapper logs in c:\Resources
  • AppAgentRuntime logs

You also can attach a debugger to WaIISHost.exe and WaWorker.exe to see what is going on and whether this helps with debugging.

Summary

In this article, we learned about tips on how to debug cloud applications.  I hope you have found this information useful.

About the Author

Vipul Patel is a technology geek based in Seattle. He can be reached at vipul.patel@hotmail.com. You can visit his LinkedIn profile at https://www.linkedin.com/pub/vipul-patel/6/675/508.


Tags: Azure, VM, PaaS, IaaS, emulator, Azure Cloud, cloud applications, IntelliTrace, Windows Azure Diagnostics, WAD, ETW events




Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel