how to do a performance audit of your .net website

33
How to do a Performance Audit of your .NET Website Bruce Chapman

Upload: dnn

Post on 19-Jan-2017

2.243 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: How to Do a Performance Audit of Your .NET Website

How to do a Performance Audit of your .NET Website

Bruce Chapman

Page 2: How to Do a Performance Audit of Your .NET Website

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

Page 3: How to Do a Performance Audit of Your .NET Website

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

Page 4: How to Do a Performance Audit of Your .NET Website

Our Example Site

Evoq 8.5 Build (DNN Platform Base)

Site has been modified to add in performance problems.

Home Page Products Page

Page 5: How to Do a Performance Audit of Your .NET Website

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

Page 6: How to Do a Performance Audit of Your .NET Website

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

Page 7: How to Do a Performance Audit of Your .NET Website

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

Page 8: How to Do a Performance Audit of Your .NET Website

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)

Page 9: How to Do a Performance Audit of Your .NET Website

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

Page 10: How to Do a Performance Audit of Your .NET Website

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

Page 11: How to Do a Performance Audit of Your .NET Website

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)

Page 12: How to Do a Performance Audit of Your .NET Website

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

Page 13: How to Do a Performance Audit of Your .NET Website

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

Page 14: How to Do a Performance Audit of Your .NET Website

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

Page 15: How to Do a Performance Audit of Your .NET Website

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

Page 16: How to Do a Performance Audit of Your .NET Website

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?

Page 17: How to Do a Performance Audit of Your .NET Website

Analysis Tool – Glimpse

• Open Source .NET Analysis Platform

• Runs as a Diagnostics tool against server side code

• Installed as a Component on the Server

Page 18: How to Do a Performance Audit of Your .NET Website

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

Page 19: How to Do a Performance Audit of Your .NET Website

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

Page 20: How to Do a Performance Audit of Your .NET Website

Reading Trace with Glimpse

Glimpse Trace Output

- Shows Trace Statements inserted

- Differential Time count shows slow

statements

Page 21: How to Do a Performance Audit of Your .NET Website

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.

Page 22: How to Do a Performance Audit of Your .NET Website

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

Page 23: How to Do a Performance Audit of Your .NET Website

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)

Page 24: How to Do a Performance Audit of Your .NET Website

Record Slow Queries

Query text & Speed recorded in Performance Audit Report

Page 25: How to Do a Performance Audit of Your .NET Website

Step 4 : Browser Resource Performance

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

Select slow

items for more

information

Page 26: How to Do a Performance Audit of Your .NET Website

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

Page 27: How to Do a Performance Audit of Your .NET Website

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

Page 28: How to Do a Performance Audit of Your .NET Website

Analysis Tools - Server Resources

• Check Server Resources during running

Process Explorer (Sysinternals Suite)

• Inspect individual threads

• Identify memory leaks

Windows Task

Manager

Page 29: How to Do a Performance Audit of Your .NET Website

Completed Performance Audit Report

Guide for reporting

and list of items to fix

Page 30: How to Do a Performance Audit of Your .NET Website

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

Page 31: How to Do a Performance Audit of Your .NET Website

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

Page 32: How to Do a Performance Audit of Your .NET Website

New WebPageTest Results

New TTFB : 255 ms

Reduced repeat requests

Reduced page size

Page 33: How to Do a Performance Audit of Your .NET Website

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