dotTrace 2024.3 Help

Profile Web Application on IIS Server

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

Pros

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

Profiling via the command-line profiler

  • No network communication required

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

  • The the command-line profiler 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 on behalf of Administrator. The dotTrace Home window will open.

  3. Add a run configuration - the configuration that tells dotTrace how to run the profiled application:

    1. Under Choose what you want to profile, New Process Run, click Add run configuration Add run configuration.

    2. In the New Run Configuration wizard, choose IIS and click Next.

    3. In Open URL, 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.

    4. Optionally, in in browser, specify the browser that dotTrace should use to open the URL.

    5. Optionally, in Set environment variables, specify required environment variables. Each variable must be specified on a new line.

    6. Click Save.

  4. Make sure the created run configuration is selected in the New Process Run list.

  5. Under Choose how you want to profile it, specify profiling options:

    • Profiling Type: typically, you should choose between Sampling (evaluate performance and determine the slowest methods in your app) and Timeline (same as Sampling but with additional timeline data). Learn more about profiling types

    • If required, specify other profiling options.

  6. If you want dotTrace to start collecting profiling data right after you start the session, under Run profiling, select Collect profiling data from start.

  7. Click Start. This will start the profiling session.

  8. Go through a particular workflow in your application (if you want to evaluate its performance) or reproduce a particular performance issue. Collect snapshots using the Get Snapshot button in the profiling controller window. Learn more about how to control the profiling session

  9. After you collect the data, either close the profiled application or detach the profiler using the Detach button in the controller window.

  10. Analyze the collected snapshots using dotTrace Viewer.

Profiling via the command-line profiler

Profiling with console tool

The command-line profiler is the best choice if you need to automate profiling, for example, for profiling your application 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 the command-line profiler 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 the command-line profiler

  1. Download the zip archive with the dotTrace.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 Working with dotTrace Command-Line Profiler).

    To attach dotTrace.exe to the running app pool:

    dotTrace.exe attach 1234 --save-to=snapshot.dtp

    where 1234 is the process ID of the corresponding w3wp.exe process.

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

    1. Get a snapshot by timeout:

      dotTrace.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 snapshot by timeout
    2. Get a snapshot on process exit. The dotTrace.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.

      Get snapshot on process exit
  4. Copy the resulting snapshot to the computer with installed dotTrace and analyze it in the dotTrace Viewer.

    Note that it is normal that the snapshots contain large amount of native code.

Last modified: 26 May 2024