how to do a performance audit of your .net website

Post on 19-Jan-2017

2.243 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

How to do a Performance Audit of your .NET Website

Bruce Chapman

The Performance Audit

Common Scenario

• Live .NET Website

• Not running to full potential

• Key stakeholders want it ‘faster’

Performance Audit

• Look at each individual part

• Know which parts to improve

What we will cover:

• Breaking down overall performance of .NET Website

• Understanding tools and processes to discover problems

• Providing a report and recommendations

Common .NET Website Architecture

Html JS Client Side Files

ASP.NET Page .NET API

SQL Database

Each Tier needs to be checked

for performance issues

Our Example Site

Evoq 8.5 Build (DNN Platform Base)

Site has been modified to add in performance problems.

Home Page Products Page

Analysis Tool - NewRelic

Multiple Purpose Server/Site Monitoring Tool

• Add Agent to .NET Application

• Add Server Agent to Windows/IIS and SQL Server

Works by:

• Monitoring code in the .NET runtime

• Injecting a beacon into sampled page loads

• Monitoring system-level resources via Server Agents

Reports via NewRelic Website

• Embeddable Reports available

• Free and Paid tiers available

Analysis Tool – Microsoft Application Insights

Performance, Exception and Diagnostic Tool

• Add agent to .NET Application

• Create Account via Azure Portal

Works by:

• Tracking Http requests

• Browser tracking via injected code

• Exception log ingestion

• Server Performance Counters

Reports via Azure Portal

• Customized Reports

• Free tiers & pay for extra data points

Step 1 : Understand the ProblemN

um

ber

of A

ffe

cte

d P

ag

es

Number of Affected Users

Problem Impact

Site

Issue

Page

Issue

Specific

Issue

Understanding the Problem

Monitoring Software

• Overall site performance

• Compare response time / load

NewRelic : Apdex Score

• Samples data to provide score

• Ratio of Satisfied/Dissatisfied

• Page & App performance

Azure Application Insights

• Average Server Response Time

• Average Page Load Time

• Individual Request drill-down • Performance Buckets

• Request Duration

• Responses by Operation (page/API)

Drill into the Problem – Identify Pages to Analyze

Page Specific Issues different to Site Issues

• High volume high performance can mask low volume low performance

Site Apdex

Home Page Apdex Product Page Apdex

High Volume,

Good Apdex

Low Volume,

Patchy Apdex

Analysis Tool : Page Load Time Chrome extension

• Simple Plug-in for Chrome

• Measures page load speed of sites

• Gives simple breakdown of load times

• Quick and Easy – gives instant feedback

Step 2 : Analyze Specific Page Performance

Quantify the performance of problem page• Multiple page browse iterations (5-20)

• Copy results into Spreadsheet

• Check for consistency/inconsistency

Check some other pages

• Find the worst page to analyse

• Confirm assumptions of page vs site issue

Server Response vs Page DOM

• Look at the slowest part first

• Look for unusual issues like DNS

• Check for consistency (add to sheet)

Analysis Tool : WebPageTest.org

Free Service for testing

pages

• Choose connection type

• Run multiple tests

• Add in custom headers

Report:

• Scores page

• Shows individual

components

• Reports have permanent

URLs to save for tests

Understanding Web Page Test Results

• First Byte : Time taken for Browser to get first response

• Start Render : When the Browser receives enough data to render

• Document Complete : All resources are loaded

• Fully Loaded : Page is completely rendered

Home page clearly has a problem – further investigation needed

Record Page Speed Values

Keep the values from the page load test

• Comparison of First/Second request shows effectiveness of caching

Add the statistics to the Performance Audit Report

Understanding Web Page Waterfall View

Waterfall View

• Sequential loading

• Colors show stages of resource load

Used to Identify:

• Slow resources

• Blocking calls

• Bandwidth & Memory requirements

Impact of TTFB on page load time

Step 3 : Analyze Server Side Performance

Server Side Performance : Making TTFB Faster

• ASP.NET Page Performance

• Database Performance

• API Performance (AJAX/SPA Code)

Key Questions

• ASP.NET Page Generation : Where is time being spent?

• API Calls : How fast are the API calls?

• Database Queries : How many, how long for?

• Server Load : How much CPU / Memory is used?

Analysis Tool – Glimpse

• Open Source .NET Analysis Platform

• Runs as a Diagnostics tool against server side code

• Installed as a Component on the Server

ASP.NET Page Performance

ASP.NET Pages – Request => [code happens] => Response

Key Questions :

• Where is time being spent? How can it run faster?

• How can we measure this in a production runtime environment?

Measurement Tool : Glimpse / Page Life Cycle

ASP.NET Page Tracing

• Glimpse can act as a tracing listener• Install Glimpse as per instructions

• Add System.Diagnostics.Trace.WriteLine(“”) calls to suspect code

DoMyStuff();

Listener

Wrapper

Add trace to web.config

Reading Trace with Glimpse

Glimpse Trace Output

- Shows Trace Statements inserted

- Differential Time count shows slow

statements

Finding Slow Database Queries with Glimpse

Glimpse shows the DB Queries/Times

The ‘SQL’ tab lists the number of queries

and the execution time.

Sometimes requires several iterations to determine

slow queries – caching and query plans may cause

intermittent slow running.

Analysis Tool – SQL Server Profiler

SQL Server Trace ships with SQL Server

• Requires elevated permissions to connect

• Traces the execution of statements

• Best results by carefully setting filters – works well with strong naming standards of Stored Procedures

Database Performance - NewRelic

Useful for Identifying Slow Procedures

• Measures time taken and individual avg response time

• Look for slow procedures running frequently : highest impact

• Does not identify slow procedures for individual requests(unless SP only run on that request)

Record Slow Queries

Query text & Speed recorded in Performance Audit Report

Step 4 : Browser Resource Performance

Waterfall Results identify long-running or slow-loading resources:

Select slow

items for more

information

Finding Oversize and Broken Resources

Images / Videos / Large CSS files

• Slow Loading Time

• File Size

Look for redirects / 404 / 401 response codes

List large Resources

Step 5: Check for Site-wide Issues

• Check for issues which may be slowing down the server• Not related to a specific page

• Hardware issues, software issues

• Exception Logs

Exception log from

Log4Net output

Analysis Tools - Server Resources

• Check Server Resources during running

Process Explorer (Sysinternals Suite)

• Inspect individual threads

• Identify memory leaks

Windows Task

Manager

Completed Performance Audit Report

Guide for reporting

and list of items to fix

Start Fixing the Site

•Prioritize by •Performance Gain

•Ease of Fix

•Access to Skills

•Change one thing at a time•Re-test to determine & document change

•Update Audit Report with new figures

•Repeat endlessly for continuous gains

Next Steps for fixing issues

After Fixing Example Site1.5 seconds

Fixes Made

- Scale down images to reduce

size

- Fix 404 for broken resource

- Fix slow running SQL

Procedure

- Fix slow running .NET code

Improvement : 7 seconds

New WebPageTest Results

New TTFB : 255 ms

Reduced repeat requests

Reduced page size

Resources

NewRelic

http://www.newrelic.com

Application Insights

https://azure.microsoft.com/en-us/services/application-insights/

Page Load Timer

https://github.com/alex-vv/chrome-load-timer

Web Page Test

http://webpagetest.org/

Glimpse

http://getglimpse.com/

Process Explorer https://technet.microsoft.com/en-us/processexplorer

To learn more about our .NET CMS:

http://www.dnnsoftware.com

top related