Remote Profiling with dotTrace Performance

You’ve got a thorny performance problem, but it only happens in your staging and production environments. For some reason, you just can’t seem to reproduce it on your local machine. What’s a developer to do? Fortunately dotTrace can profile a remote application and with dotTrace 5.2, it’s easier than ever before. Let’s walk through the steps of collecting a performance snapshot from a remote machine.

Step 1: Copy the dotTrace Remote Agent to the remote server

First we need some way for dotTrace to connect to the remote machine. This is done using the dotTrace Remote Agent, which ships with dotTrace. It can be found in:

C:Program Files (x86)JetBrainsdotTracev5.2BinRemote

dotTrace Remote Agent directory

The contents of this directory are XCopy deployable. The target machine requires .NET 2.0 or greater installed. Simply copy the “.BinRemote” directory to the remote server using RDP, file share, or any other file copy method of your choice.

Step 2: Run the dotTrace Remote Agent on the remote server

Log into the remote server and run RemoteAgent.exe. To profile an application running as a different user (e.g. ASP.NET web app running under IIS), shift-right-click RemoteAgent.exe and select “Run as administrator”. A console window similar to the one below will appear:

dotTrace Remote Agent running

By default, the Remote Agent will listen on all network interfaces and both IPv4 and IPv6 protocols. Network traffic happens over HTTP and it defaults to port 9000. You can configure a variety of options if you need to change the defaults. Run `RemoteAgent.exe /?` for a full list of options. You will need to configure your firewall to allow TCP traffic on port 9000 (or whichever port you configured with the /port=VALUE option).

Step 3: Attach to the dotTrace Remote Agent from dotTrace on your local machine

Once the Remote Agent is running on the remote computer, you can connect to it from dotTrace running on your local machine using the “Attach To Process” button in dotTrace.

Attach to Process

If you haven’t remotely profiled an application before, click on the “Profile on remote computer” link to bring up the Add Host dialog. If you have remotely profiled an application before, but not on this remote server, click the Add… button and enter the Remote Agent URL for that remote computer.

Profile App

Add Host

The Remote Agent URL will look like http://URL:PORT/RemoteAgent/AgentService.asmx. If you have connected to the remote computer before, it will be available in the drop down list.

Step 4: Profile the application

After the remote computer is selected, a list of .NET 4.0 and above processes will be displayed. Due to limitations of the .NET Profiler API, it is only possible to attach to processes running .NET 4.0 and above.

Profile App with Connection to Remote Server

Choose whether you want to start profiling immediately or whether you would like to start with profiling disabled and click “Run”. The usual dotTrace profiling control dialog will appear. The only difference is that the performance data is being acquired on the remote computer.

dotTrace profiling control dialog

Step 5: Get Snapshot and Analyze

Exercise the remote application in a way that demonstrates the performance problem and click “Get Snapshot”. The performance snapshot will automatically be downloaded to dotTrace and opened – ready for analysis.

Analyze snapshot

You can analyze the snapshot data just as if you had recorded the snapshot locally. After determining the root cause and deploying a fix, you can repeat the process to collect another snapshot and verify that you have resolved the performance problem.

Profile with pleasure!

This entry was posted in dotTrace Tips&Tricks, How-To's and tagged , , . Bookmark the permalink.

4 Responses to Remote Profiling with dotTrace Performance

  1. Igor Skomorokh says:

    Will those actions force profiled process to be restarted?

  2. jkovacs says:

    @Igor – Attaching to a running process will not restart it. Attaching to a running process only works for .NET 4.0 and 4.5 applications due to limitations in the Profiler API. The list of available processes does not include .NET 3.5 and below for this reason. When you are done profiling, you have the option to detach from the process and leave it running or kill the process.

  3. EdwardB says:

    How does this work in Shared hosting environments where RDP is not allowed?

    Thanks.

  4. Daria.Dovzhikova says:

    @Edward to be able to profile remote applications you need to install dotTrace Profiler’s Remote Agent to the server with “run as administrator” permissions, and configure the port so you could access it. Can you tell a bit more about your environment?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>