identify & fix performance problems with visual studio 2012 ultimate benjamin day benjamin day...

74

Upload: derick-gregory

Post on 23-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday
Page 2: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Identify & Fix Performance Problems with Visual Studio 2012 UltimateBenjamin DayBenjamin Day Consulting, Inc.benday.com/blog | @benday

Page 3: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

About Me

Cambridge, MAConsultant, Coach, & TrainerMicrosoft MVP for Visual Studio ALMTeam Foundation Server, Software Testing, Scrum, Software ArchitectureScrum.org Classes

Professional Scrum Developer (PSD)Professional Scrum Foundations (PSF)

www.benday.com, [email protected], @benday

Page 4: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Have you heard of Scrum.org?

Page 5: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday
Page 6: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

http://www.pluralsight.com/training/Courses/TableOfContents/alm-fundamentals

Page 8: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Thanks.

To my content reviewersJerri Chiu, MicrosoftDennis Bass, Microsoft

Page 9: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Agenda

Basics of Web Performance TestsLoad TestsLoad Test RigsPerformance Explorer

Existing application Identify performance problemsGo from bad performance to good

Page 10: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday
Page 11: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Purpose of Load Testing

Identify the capabilities of your applicationPossible goals

ExploreVerify Find the limitsCrush

Page 12: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Obligatory “Eat Your Vegetables” Slide.

Load test throughout the development cycle.

Catch problems earlyEstablish performance baselineWatch for performance trends

Cheaper to fix early

Plan for performance

Best Practice

Page 13: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Cheaper to Fix Early

Early Less Early Nearly Done Production0

10

20

30

40

50

60

Time

Cost

to fi

x

Page 14: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Dose Of Reality

You know you should work that way.You probably don’t.

This talk is for you.

You have problems.How do you figure out what’s going wrong?

Page 15: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Inspiration for this talk

Real customer engagementSpent years developing a web applicationReleased it Seriously grumpy customersHuge hardware~20 simultaneous usersFixed it

4000+ simultaneous usersReduced hardware

Page 16: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Tools

Visual Studio Ultimate

• Web Performance Tests• Load Tests• Load Test Rigs

Visual Studio Premium

• Profiling Tools• Performance Wizard

Page 17: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Tour of the application.

Page 18: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Disaster Strikes.

The application is deployed to production.Users are losing their minds.

Intermittent errors on the site.Site is slow.

Your boss is seriously angry.“Fix it!”

Page 19: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Problem.

“No Repro”“Works on my box.”You don’t know what the errors are.The site seems to work fine.

Wild guess: it dies under load.

You need to create some load.

Page 20: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance Wizard6. Fix the code

Page 21: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Web Performance Tests.

Page 22: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests

2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance Wizard6. Fix the code

Page 23: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

What is a Web Performance Test?

Test type in Visual Studio 2012 UltimateSimulate a user using an ASP.NET application

HTTP trafficBuilding block of Load Tests

Page 24: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Tip: Web Tests & User Stories

Web Tests should simulate a User StoryExample:

As an administrator, I need to search for a person by username so that I can deactivate that person’s account.As a customer, I want to order a pizza and pay with a credit card.

Helps to organize your suite

Page 25: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Create a basic Web Test

Page 26: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Data-driven Web Tests

Run web test once per row in data sourceSimulate multiple users doing *similar* actionsData source types

OLE DB, CSV, XMLParameterization

Better tests, better coverage

Page 27: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Web Tests in the underperforming app

Page 28: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Load Tests.

Page 29: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance Wizard6. Fix the code

Page 30: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

What are Load Tests?

Mix of Web Performance and Unit Tests

Simulates a mix of users doing a mix of things

Simulate Network speedsDifferent browsersVarying user activity loads

Page 31: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Why would you put a Unit Test in a Load Test?

Helpful for testing WCFCumbersome to simulate WCF via Web Test

(You’d have to re-invent the wheel.)Unit tests can re-use the WCF libraries

(Done and done.)

Important for Silverlight and SOAhttp://wcfloadtest.codeplex.com/http://sqlloadtest.codeplex.com/

Page 32: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

(Hooray!)

“Hey Kids,Let’s create some Load Tests!”

Page 33: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Running load tests.

Page 34: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance Wizard6. Fix the code

Page 35: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Two ways to run load tests.

Generate load from Visual Studio 2012Uses only 1 core/processorLimited to 250 simulated users

Generate load from a Test RigFar better testSimulate lots more users

Page 36: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Load Test Rig & The Application

ControllerOrchestratesLicensingPerfMon Counters

Agent (1..n)Simulates users

Controller

Agent 1

Web Server

Database

Agent 2

Agent n

Coordinates & Gathers Information

Generates Load

Application Under Test

Page 37: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Load Test Rig: Manage Test Controller

Page 38: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Load Test Rig: Test Settings

Page 39: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Load Test Rig: Remote Execution

Page 40: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance Wizard6. Fix the code

Page 41: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Run Load Tests on the Rig

Page 42: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Before: Load Test Summary

Page 43: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Before: Load Test Graphs

Page 44: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Core Problem.

Page 45: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

‘sp_who2’ says lots of open connections.

Page 46: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

After: Load Test Summary

Page 47: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

After: Load Test Graphs

Page 48: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Performance Profiling

Page 49: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance

Wizard6. Fix the code

Page 50: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Profiling Tools

Load Tests help you find issues in a system“Surface” issues

Profiling helps you find issues in the code

Unit Tests, Web Tests, Load TestsRepeatableGood for targeted tuning

System under “natural” loadNot repeatableLooking for rough patterns

Page 51: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Profiling Methods•Gathers information at intervals (clock cycles)•No code modifications•Use this for first pass explorationsSampling•Modifies your code•Gathers detailed timing and count information

Instrumentation

•Multi-threaded code profilingConcurrency

•Object creation•Garbage collection.NET Memory

•Interaction between your application and SQL Server via ADO.NET

Tier Interaction

Page 52: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Load Test Performance Sessions Via Wizard

Must be only Web Performance TestsCan’t profile via Load Test Rig

Page 53: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Let’s go profile some stuff.

Page 54: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

The Plan.

1. Script user activity with Web Performance Tests2. Simulate a mix of users using Load Tests3. Simulate lots of users with a Load Test Rig4. Reproduce the errors...hopefully5. Find code problems with the Performance Wizard6. Fix the code

Page 55: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Any last questions?

Page 56: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

For More Information: Articles

Uses Visual Studio 2012

http://tinyurl.com/8sdjjak

Page 57: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

For More Information: Articles

Uses Visual Studio 2010

http://tinyurl.com/3xjqgvz

http://tinyurl.com/2ulvvvr

Page 58: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

For More Information: Microsoft Links

Visual Studio Performance Testing Quick Reference Guidehttp://vsptqrg.codeplex.com/ Content Index for Web Tests & Load Testshttp://tinyurl.com/ye97e52

Page 59: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

For More Information: Microsoft Bloggers

VS Team Test Blog Site http://blogs.msdn.com/b/vstsqualitytools/Ed Glas - http://blogs.msdn.com/edglas/Bill Barnett - http://blogs.msdn.com/billbar/Sean Lumley - http://blogs.msdn.com/slumley/Dennis Stone - http://blogs.msdn.com/densto/Mike Taute - http://blogs.msdn.com/mtaute/Neelesh Kamkolkar - http://blogs.msdn.com/b/nkamkolkar/

Page 60: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Thank you.

http://www.benday.com | [email protected]

Page 61: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.

Page 62: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Miscellaneous tips.

Page 63: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Include Load Tests In Your Nightly Build

Create a Test List (*.vsmdi)Include the Test List in the buildCaptures trend data at 24 hours intervalsCompare the load test data with Excel

Page 64: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Static Code Analysis / FxCop

Help you to find issues in your codeShow you IDispose errors

Rules are configurableUse your judgment about which are relevant for your team

Page 65: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Avoid Static Methods & CA1822

Static Code Analysis Rule CA1822 is evil.

Sacrifices maintainability for perfomance.

Blog post: “Static Methods Are A Code Smell”http://bit.ly/cnEsuV

Page 66: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Only optimize known performance problems.

You’d be surprised by what *ISN’T* a performance problemDon’t spend a ton of time coding fancy solutions to performance problems you *THINK* you might haveFind and fix *REAL* problems

Page 67: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Tip: WCF Message Size

Data structure formatting can make a huge differenceExample: Banks and the States they operate inOption 1: Dictionary<string, string>

Key = Bank IdValue = State Abbreviation

Option 2: Dictionary<string, string[]>Key = State AbbreviationValue = Array of Bank Id’s

Option 2 was approximately 90% smaller

Page 68: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Tip: Add Performance Counters

Create Performance Counters (perfmon) in your appDo this early in the development cycle

More directed profiling of your app during Load Tests

Good for managing your app when it’s in production(Operations people love this.)

Page 69: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Using Performance Sessions on x64

You can’t profile x64 IIS processes from the IDE

Option #1: Profile from the command lineStart ASP.NET profiling using VSPerfAspNetCmd.exe Run the web test

Option #2: Run the ASP.NET process in x86 mode

Page 70: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

How To Run ASP.NET in x86 Mode

Set “Enable 32-bit Applications” to true on your application’s AppPool

Page 71: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Resources

Connect. Share. Discuss.

http://northamerica.msteched.com

Learning

Microsoft Certification & Training Resources

www.microsoft.com/learning

TechNet

Resources for IT Professionals

http://microsoft.com/technet

Resources for Developers

http://microsoft.com/msdn

Page 72: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

Complete an evaluation on CommNet and enter to win!

Page 73: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

MS Tag

Scan the Tagto evaluate thissession now onmyTechEd Mobile

Required Slide *delete this box when your slide is finalized

Your MS Tag will be inserted here during the final scrub.

Page 74: Identify & Fix Performance Problems with Visual Studio 2012 Ultimate Benjamin Day Benjamin Day Consulting, Inc. benday.com/blog | @benday

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to

be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS

PRESENTATION.