asp.net performance tips and tricks

109
ASP.NET Quick Wins 20 Tips and Tricks To Shift Your Application into High Gear Kevin Griffin twitter.com/1kevgriff [email protected]

Upload: kevin-griffin

Post on 02-Jul-2015

696 views

Category:

Technology


4 download

DESCRIPTION

Out of the box, ASP.NET can do a lot of amazing things. The tools and framework have grown to make mundane tasks, such as minification, simple to implement. Many times by using the framework as we were taught, opportunities to optimize pass us by. The reality is that underneath the covers, there is a whole world of easy tweaks we can implement to help ASP.NET perform at its peak. In this presentation, we will walk through a slew of tweaks used to make ASP.NET perform in the best way possible. You will leave with a checklist of tasks that will instantly improve the performance of your web application!

TRANSCRIPT

Page 1: ASP.NET Performance Tips and Tricks

ASP.NET Quick Wins20 Tips and Tricks To Shift Your Application into High Gear

Kevin Griffintwitter.com/[email protected]

Page 2: ASP.NET Performance Tips and Tricks

Hello!

Kevin GriffinIndependent ConsultantMicrosoft MVP, ASP.NET

[email protected]

@1kevgriff

Page 3: ASP.NET Performance Tips and Tricks

Now Accepting Pre-Orders!

Special CodeMash Deal! Ends at midnight Friday. Get on email list!

$15 $39

http://TwilioBlueprint.com/Codemash

Page 4: ASP.NET Performance Tips and Tricks

RevolutionConf

May 13th, 2016Virginia Beach, VA

RevolutionConf.com

Page 5: ASP.NET Performance Tips and Tricks

Want Slides? Conversation?

Let’s continue the conversation after Codemash! Put your name and email address on the clipboard, and I’ll send you a blast next week after we have all had time to recover!

No spam, just conversation.

Page 6: ASP.NET Performance Tips and Tricks

Defining Performance

Page 7: ASP.NET Performance Tips and Tricks

Performance is the amount

of time a person will wait

before getting pissed off.

Page 8: ASP.NET Performance Tips and Tricks

Performance is sweating

because you have ONLY 16

cores and 32 gigs of RAM.

Page 9: ASP.NET Performance Tips and Tricks

The Great Scale of Performance

Done before you ask Throw Computer Out the Window

Page 10: ASP.NET Performance Tips and Tricks

The Great Scale of Performance

Done before you ask Throw Computer Out the Window

ASP.NET Application After File, NewGoogle

Visual Studio

Page 11: ASP.NET Performance Tips and Tricks

Why

Performance?

Page 12: ASP.NET Performance Tips and Tricks

3 Numbers to

Remember

Page 13: ASP.NET Performance Tips and Tricks

100

milliseconds

Page 14: ASP.NET Performance Tips and Tricks

1 second

Page 15: ASP.NET Performance Tips and Tricks

10 seconds

Page 16: ASP.NET Performance Tips and Tricks

Did you know: Google will

rank a slower loading

website below a faster one.

Page 17: ASP.NET Performance Tips and Tricks

The number of mobile device

users is growing by the daily.

They hate slow websites.

Page 18: ASP.NET Performance Tips and Tricks

Two simple rules for

better performance

Page 19: ASP.NET Performance Tips and Tricks

Fewer

payloads

Page 20: ASP.NET Performance Tips and Tricks

Faster

payloads

Page 21: ASP.NET Performance Tips and Tricks

20 ASP.NET Quick

Wins

Page 22: ASP.NET Performance Tips and Tricks

#1

Page 23: ASP.NET Performance Tips and Tricks

Disable “debug”

mode

Page 24: ASP.NET Performance Tips and Tricks
Page 25: ASP.NET Performance Tips and Tricks
Page 26: ASP.NET Performance Tips and Tricks

#2

Page 27: ASP.NET Performance Tips and Tricks

Enable HTTP

Compression

Page 28: ASP.NET Performance Tips and Tricks
Page 29: ASP.NET Performance Tips and Tricks

What gets compressed?

• HTML

• JavaScript

• JSON

• CSS

• XML

• Non-compressed images (ico)

Page 30: ASP.NET Performance Tips and Tricks

#3

Page 31: ASP.NET Performance Tips and Tricks

Enable IIS

Auto-Start

Page 32: ASP.NET Performance Tips and Tricks

Do you have a lot of

upfront loading and

configuration?

Page 33: ASP.NET Performance Tips and Tricks
Page 34: ASP.NET Performance Tips and Tricks

#4

Page 35: ASP.NET Performance Tips and Tricks

Disable ViewState

Page 36: ASP.NET Performance Tips and Tricks

Ways to Disable

• Control • Add EnableViewState=“false” to

control

• Page• Add EnableViewState=“false” to

the <%@ Page %> construct

• Application<configuration>

<system.web>

<pages enableViewState="false" />

</system.web>

</configuration>

• Machine<Machine.config >

<system.web>

<pages enableViewState="false" />

</system.web>

</Machine.config>

Page 37: ASP.NET Performance Tips and Tricks

#5

Page 38: ASP.NET Performance Tips and Tricks

STOP using

WebForms

Page 39: ASP.NET Performance Tips and Tricks

I’m just kidding.

Page 40: ASP.NET Performance Tips and Tricks

But seriously,

stop it.

Page 41: ASP.NET Performance Tips and Tricks

#6

Page 42: ASP.NET Performance Tips and Tricks

Disable

SessionState

Page 43: ASP.NET Performance Tips and Tricks

Ways to Disable

• Application • Page

Page 44: ASP.NET Performance Tips and Tricks

#7

Page 45: ASP.NET Performance Tips and Tricks

Throw hardware at it!

Page 46: ASP.NET Performance Tips and Tricks

Stop it!

Page 47: ASP.NET Performance Tips and Tricks

Processors are

cheap.

RAM is cheap.

Page 48: ASP.NET Performance Tips and Tricks
Page 49: ASP.NET Performance Tips and Tricks

#8

Page 50: ASP.NET Performance Tips and Tricks

Minify/Compress

JavaScript and CSS

Page 51: ASP.NET Performance Tips and Tricks
Page 52: ASP.NET Performance Tips and Tricks
Page 53: ASP.NET Performance Tips and Tricks

#9

Page 54: ASP.NET Performance Tips and Tricks

Output Cache

Page 55: ASP.NET Performance Tips and Tricks
Page 56: ASP.NET Performance Tips and Tricks
Page 57: ASP.NET Performance Tips and Tricks

Caching Options

• Duration (in seconds)

• Location• Client

• Server

• Proxies

• VaryByParam

• VaryByHeader

• SqlDependency

Page 58: ASP.NET Performance Tips and Tricks

#9b

Page 59: ASP.NET Performance Tips and Tricks

Cache “look up”

tables

Page 60: ASP.NET Performance Tips and Tricks

#10

Page 61: ASP.NET Performance Tips and Tricks

Stop shipping the

kitchen sink

Page 62: ASP.NET Performance Tips and Tricks
Page 63: ASP.NET Performance Tips and Tricks
Page 64: ASP.NET Performance Tips and Tricks

#11

Page 65: ASP.NET Performance Tips and Tricks

Async

Page 66: ASP.NET Performance Tips and Tricks

.NET Async Features

• Speeds up parallel processes

• Useful if your page needs to talk to several data sources

Page 67: ASP.NET Performance Tips and Tricks
Page 68: ASP.NET Performance Tips and Tricks
Page 69: ASP.NET Performance Tips and Tricks
Page 70: ASP.NET Performance Tips and Tricks
Page 71: ASP.NET Performance Tips and Tricks
Page 72: ASP.NET Performance Tips and Tricks
Page 73: ASP.NET Performance Tips and Tricks

#12

Page 74: ASP.NET Performance Tips and Tricks

CDNs and

Subdomains

Page 75: ASP.NET Performance Tips and Tricks

CDNs and Subdomain

• Modern browsers limit downloads from a single domain.

http://assets.kevgriffin.com/images/2014/foo.png

could be better as

http://a1.assets.kevgriffin.com/images/2014/foo.png

Page 76: ASP.NET Performance Tips and Tricks
Page 77: ASP.NET Performance Tips and Tricks

#13

Page 78: ASP.NET Performance Tips and Tricks

Glimpse

Page 79: ASP.NET Performance Tips and Tricks

http://getglimpse.com

Page 80: ASP.NET Performance Tips and Tricks
Page 81: ASP.NET Performance Tips and Tricks
Page 82: ASP.NET Performance Tips and Tricks
Page 83: ASP.NET Performance Tips and Tricks
Page 84: ASP.NET Performance Tips and Tricks
Page 85: ASP.NET Performance Tips and Tricks
Page 86: ASP.NET Performance Tips and Tricks

#14

Page 87: ASP.NET Performance Tips and Tricks

Upgrade Your User

Experience

Page 88: ASP.NET Performance Tips and Tricks
Page 89: ASP.NET Performance Tips and Tricks
Page 90: ASP.NET Performance Tips and Tricks

#15

Page 91: ASP.NET Performance Tips and Tricks

ORM

Considerations

Page 92: ASP.NET Performance Tips and Tricks

Test code-generated

“read” vs Stored

Procedures

Page 93: ASP.NET Performance Tips and Tricks

Optimize for Ad Hoc

Queries

Page 94: ASP.NET Performance Tips and Tricks
Page 95: ASP.NET Performance Tips and Tricks

#16

Page 96: ASP.NET Performance Tips and Tricks

Dispose SQL

Connections

Appropriately

Page 97: ASP.NET Performance Tips and Tricks
Page 98: ASP.NET Performance Tips and Tricks

#17

Page 99: ASP.NET Performance Tips and Tricks

Hire a DBA to Optimize

Database Indexes and

Stored Procedures

Page 100: ASP.NET Performance Tips and Tricks

Or if you must “do it yourself”

• Create indexes for columns used inside of:• WHERE clauses

• JOIN clauses

• ORDER BY clauses

• GROUP clauses

• TOP clauses

Page 101: ASP.NET Performance Tips and Tricks

Or if you must “do it yourself”

• Don’t do SELECT *

Page 102: ASP.NET Performance Tips and Tricks

#18

Page 103: ASP.NET Performance Tips and Tricks

Consider Alternative

Data Stores

Page 104: ASP.NET Performance Tips and Tricks

Alternatives

• MongoDB

• RavenDB

• Redis

• Azure Tables

Page 105: ASP.NET Performance Tips and Tricks

#19

Page 106: ASP.NET Performance Tips and Tricks

Embrace Workflow

Page 107: ASP.NET Performance Tips and Tricks

Workflow

• Message-based workflows

• Examples: RabbitMQ, ZeroMQ, Azure Queues, etc

• Offload long running and critical tasking

• Example: Twitter, Amazon

Page 108: ASP.NET Performance Tips and Tricks

#20

Page 109: ASP.NET Performance Tips and Tricks

Hire Me

Kevin GriffinIndependent ConsultantMicrosoft MVP, ASP.NET

[email protected]

@1kevgriff