dotTrace 2019.3 Help

Profile Web Application on IIS Server

Typically, determining performance issues in a web application is required when it is already running on a server. The table summarizes all possible options of profiling the application:

Pros

Not cons but features

Local profiling
  • Easy to configure/use: you profile via the dotTrace GUI

  • dotTrace must be installed and run on the server, which may be impossible due to security restrictions, absence of GUI, etc

Remote profiling
  • Easy to configure/use: you profile via the dotTrace GUI

  • Snapshots are automatically uploaded to your local machine

  • dotTrace remote agent must be installed and run on the server

  • Communication via network is required

Profiling via console tools
  • No network communication required

  • Ability to create a number of predefined profiling configs and run them on demand

  • The console tools must be copied to and run on the server

  • Resulting snapshots must be manually copied from the server to the machine with dotTrace

Local profiling

Local profiling

Typically, local profiling is used when you need to profile the app that is hosted right on your (developer's) machine or on some testing environment, which doesn't impose any security/performance restrictions.

To locally profile a web app hosted on an IIS server

  1. Install dotTrace on the server.

  2. Run dotTrace as a standalone application . The dotTrace Home window will open.

  3. In the right panel, select Profile Local App.

  4. In the central panel, in Profile Application, select IIS.

  5. In the right panel, in Application Options, select Open URL and specify the URL of the profiled application. If you do not do this, dotTrace will start profiling of the first running application pool it'll be able to find.

  6. In the right panel, in Profiler Options, specify profiling type.
    For more details on profiler options, refer to the Profiler Options section.

  7. Optionally, if you are going to control profiling session (take snapshots, end session, and so on) using the API (rather than the Controller window), select Control profiling via API. For more details on how to control profiling using the API, refer to the Controlling Profiling Session Through API chapter.

  8. Click Run. Note that after you do this, the IIS service and, as a consequence, the profiled application pool will be restarted.

  9. Take snapshots. For more details on how to control profiling session, refer to Controlling Profiling Session (if you control profiling manually) or to Controlling Profiling Session Through API (if you control profiling using the API).

  10. After you collect the snapshot(s), click Detach on the Controller window to detach the profiler from the application pool.

  11. Analyze the collected snapshots either in the Performance Viewer or Timeline Viewer (depends on the profiling type you select).
    Note that it is normal that the snapshots contain large amount of native code.

Remote profiling

Remote profiling

Remote profiling is the best choice when it comes to a sudden performance drop / memory issue.

How it works: dotTrace is running on your local machine, the remote agent is running on the server, both communicating via TCP, as easy as that. The best thing about remote profiling is that you still work with the easy to use dotTrace GUI and the collected snapshots are automatically copied to and opened in dotTrace.

To remotely profile a web app hosted on an IIS server

  1. On the web server, do the following:

    • Copy the RemoteAgent.zip archive from the dotTrace installation directory on your local computer (by default, C:\Users\[username]\AppData\Local\JetBrains\Installations\dotTrace[N]) to any directory on the server.

    • Unpack the archive on the server.

    • Start RemoteAgent.exe from the console on the server.

    • Ensure that inbound connections to Remote Agent (by default, port 9100) are not blocked by the firewall.

  2. On the local computer, run dotTrace as a standalone application run dotTrace as a standalone application. The dotTrace window will open.

  3. In the right panel, select New Session | Profile Remote App.

  4. In the central panel, specify the address of the remote agent service in Remote Agent URL.
    By default, the URL is net.tcp://[remote_computer_IP_address]:9100/RemoteAgent.

  5. Click Connect to establish connection with the remote host.

  6. In the central panel, in Attach to Running Application select the w3wp.exe process that corresponds to the app pool running the profiled application.

  7. Optionally, if you are going to control profiling session (take snapshots, end session, and so on) using the API (rather than the Controller window), select Control profiling via API. For more details on how to control profiling using the API, refer to Controlling Profiling Session Through API.

  8. In the right panel, click Run.

  9. Take snapshots. For more details on how to control profiling session, refer to Controlling Profiling Session (if you control profiling manually) or to Controlling Profiling Session Through API (if you control profiling using the API).

  10. After you collect the snapshot(s), click Detach on the Controller window to detach the profiler from the application pool.

  11. Analyze the collected snapshots either in the Performance Viewer or Timeline Viewer (depends on the profiling type you select).
    Note that it is normal that the snapshots contain large amount of native code.

Profiling via console tools

Profiling with console tool

Console tools are the best if you need to automate profiling: for example, you should profile your web app from time to time. Another possible scenario is when you don't have access to the server but some other person does, so you can provide them with profiling tools and a batch file.

How does it work? In short, you copy console tools to the server and either run the app under profiling (the app pool will be restarted) or attach the tool to the running application pool w3wp.exe.

To profile a web app on an IIS server using console tools

  1. Download the zip archive with the ConsoleProfiler.exe tool and copy/unpack it to the server.

  2. Now, you should start profiling of the application pool that hosts your application: you can either attach to an already running app pool or start a new one under profiling. Starting the new one doesn't give you any advantages over attaching, so, we'll take a look only at the latter (you can still find all the details in Profiling applications using the command-line tool).
    To attach ConsoleProfiler.exe to the running app pool:

    ConsoleProfiler.exe attach 1234 --save-to=snapshot.dtp
    where 1234 is the process ID of the corresponding w3wp.exe process.
    Tip: To get the ID, in IIS Manager, open the required server. On Worker Processes page, you will find the list of running workers and their IDs.

  3. When it comes to taking performance snapshots, you have two options:

    • Get a snapshot by timeout:

      ConsoleProfiler.exe attach 1234 --save-to=snapshot.dtp --timeout=5m
      here the snapshot will be taken after 5 minutes, then the profiler will detach from the process.

    • Get a snapshot on process exit. The ConsoleProfiler.exe tool will take a snapshot once the profiled application successfully finishes its work (so, if the app is "killed", no snapshot is collected). To make this happen, you can, for example, Recycle the corresponding application pool in the IIS Manager.

  4. Copy the resulting snapshot to the computer with installed dotTrace and analyze it either in the Performance Viewer or Timeline Viewer (depends on the profiling type you select).
    Note that it is normal that the snapshots contain large amount of native code.

Last modified: 16 April 2020