Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

21
Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012 Brad Sullivan [email protected]

description

More info on http://www.techdays.be

Transcript of Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Page 1: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012Brad [email protected]

Page 2: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Agenda

• Challenges in Production• Visual Studio Tools• Remote Debugger• IntelliTrace• Dump Debugger• Profiler

• Sources and Symbols

Page 3: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Challenges in Production

• Can’t reproduce the issue in a development environment• Can’t run Visual Studio on the production machine• Possibly very limited developer access to production machines

• Want to minimize impact to the server• Performance• Availability• Security

Page 4: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Remote Debugger: The Big Hammer• Advantages• Often the fastest way to resolve an issue• Xcopy deployable (%ProgramFiles%\Microsoft Visual Studio 11.0\

Common7\IDE\Remote Debugger)• Configurable Authentication

• Disadvantages• Your service becomes unresponsive if you are stopped in the

debugger• Requires some firewall configuration

Page 5: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Remote Debugger

Client Side Server Side

Visual Studio

msvsmon.exe

TCP/IP

YourApp.exe

Page 6: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Improvements in Visual Studio 2012• Single Firewall Configuration (Remote Debugger Side)• Can connect across different domains• Symbols load from the Visual Studio side• No need to copy symbol files to your production machine

• Faster• No need to choose between x86 and x64

Page 7: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

IntelliTrace

• A “Back-in-Time” debugger• Configurable logging to trace the state of an application over

time• Integrated with the Visual Studio Debugger UI for analysis• Can be run either locally or via command line

Page 8: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

IntelliTrace in Production

• Download the IntelliTrace Collectorhttp://www.microsoft.com/en-us/download/details.aspx?id=30665

• Run it on your production machine• Pick a collection plan• Target the application• Reproduce the issue

• Bring the IntelliTrace log back to your development machine• Analyze in Visual Studio to find the bug

Page 9: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

IntelliTrace Collection Plans

• 2 Default Levels• Calls• Events

• Custom?• Requires Editing XML• Can turn individual events on/off• Can include/exclude modules• Change max log file size

Page 10: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Impact on Server Performance

• Depends on a number of factors• Number of events collected• Number of modules included in application (startup jitting costs)• Calls data collection• IO

Page 11: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

System Center

• IntelliTrace is integrated with System Center 2012 SP1 – Operations Manager

• Application Performance Monitoring now available in an IntelliTrace format

• IntelliTrace Profiling Management Pack allows you to collect IntelliTrace logs directly from the Operations Manager console

Page 12: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Dump Files

• Snapshots of the application at a single point in time• Two major types• With Heap – allows full inspection of the state of the app at that point

in time• Without Heap – only allows for inspection of the callstacks across all

threads• Can be opened directly in VS and debugged just like a regular

application• Except no stepping…

Page 13: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Creating Dump Files in Production• Several tools available that can create dump files, including

Visual Studio• ProcDump has many qualities that make it ideal for

production use• Command line• Xcopy deployable• Provides triggers for dump collection• CPU usage• Memory usage• Exceptions (with filters)

• Low impact on system performance• Available through Microsoft SysInternals:

http://technet.microsoft.com/en-us/sysinternals/dd996900.aspx

Page 14: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Performance Profiler Overview

• CPU Sampling• Shows what parts applications are executing the most frequently

• Instrumentation • Records how long functions take to execute and how many times they

are executed• .NET Memory Allocation• Tracks what objects are being allocated

• Resource Contention• Tracks when threads are contending for the same resource causing

slowdowns• Tier Interaction Profiling• Records database queries that go through ADO.NET

Page 15: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Profiling Use

• Can be run locally from the IDE• Can be run in production on the command line• Standalone installer included in the Visual Studio Install • “VS_INSTALL_DIRECTORY\Team Tools\Performance Tools\Setups”

• Tier Interaction Profiling• Find performance bottlenecks caused by how your application uses

your database• Is used simultaneously with another profiling method (e.g.

instrumentation)

Page 16: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Symbols (PDBs)

• The debugger, profiler, and IntelliTrace all need symbols to function properly

• Symbols provide a mapping between the binaries you are analyzing and the source code that produced them• Also provide information for determining the local variables for a

function• Symbol files must exactly match the build that you are

diagnosing

• It is easy for your development environment to get out of sync with what is in production

Page 17: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Source Indexing

• Embeds a command into the symbol file for each source file indexed

• Diagnostic tools execute this command to fetch the source file

Binary

Symbol File

Exact Match Source

Command

Source File

Page 18: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Improved User Experience

Better configuration when retrieving indexed sources• Trust a whole symbol file• Trust all symbol files

Page 19: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Using TFS Build

• Use TFS build definitions to save symbols and index sources

• Builds that are released to production should be saved indefinitely

Page 20: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

More Info About Diagnostics

ALM Team Blog: http://blogs.msdn.com/b/visualstudioalm/

Page 21: Diagnosing issues in your ASP.NET applications in production with Visual Studio 2012

Request Features

Uservoice site: http://visualstudio.uservoice.com/