asp.net performance tips and tricks
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
ASP.NET Quick Wins20 Tips and Tricks To Shift Your Application into High Gear
Kevin Griffintwitter.com/[email protected]
Now Accepting Pre-Orders!
Special CodeMash Deal! Ends at midnight Friday. Get on email list!
$15 $39
http://TwilioBlueprint.com/Codemash
RevolutionConf
May 13th, 2016Virginia Beach, VA
RevolutionConf.com
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.
Defining Performance
Performance is the amount
of time a person will wait
before getting pissed off.
Performance is sweating
because you have ONLY 16
cores and 32 gigs of RAM.
The Great Scale of Performance
Done before you ask Throw Computer Out the Window
The Great Scale of Performance
Done before you ask Throw Computer Out the Window
ASP.NET Application After File, NewGoogle
Visual Studio
Why
Performance?
3 Numbers to
Remember
100
milliseconds
1 second
10 seconds
Did you know: Google will
rank a slower loading
website below a faster one.
The number of mobile device
users is growing by the daily.
They hate slow websites.
Two simple rules for
better performance
Fewer
payloads
Faster
payloads
20 ASP.NET Quick
Wins
#1
Disable “debug”
mode
#2
Enable HTTP
Compression
What gets compressed?
• HTML
• JavaScript
• JSON
• CSS
• XML
• Non-compressed images (ico)
#3
Enable IIS
Auto-Start
Do you have a lot of
upfront loading and
configuration?
#4
Disable ViewState
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>
#5
STOP using
WebForms
I’m just kidding.
But seriously,
stop it.
#6
Disable
SessionState
Ways to Disable
• Application • Page
#7
Throw hardware at it!
Stop it!
Processors are
cheap.
RAM is cheap.
#8
Minify/Compress
JavaScript and CSS
#9
Output Cache
Caching Options
• Duration (in seconds)
• Location• Client
• Server
• Proxies
• VaryByParam
• VaryByHeader
• SqlDependency
#9b
Cache “look up”
tables
#10
Stop shipping the
kitchen sink
#11
Async
.NET Async Features
• Speeds up parallel processes
• Useful if your page needs to talk to several data sources
#12
CDNs and
Subdomains
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
#13
Glimpse
http://getglimpse.com
#14
Upgrade Your User
Experience
#15
ORM
Considerations
Test code-generated
“read” vs Stored
Procedures
Optimize for Ad Hoc
Queries
#16
Dispose SQL
Connections
Appropriately
#17
Hire a DBA to Optimize
Database Indexes and
Stored Procedures
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
Or if you must “do it yourself”
• Don’t do SELECT *
#18
Consider Alternative
Data Stores
Alternatives
• MongoDB
• RavenDB
• Redis
• Azure Tables
#19
Embrace Workflow
Workflow
• Message-based workflows
• Examples: RabbitMQ, ZeroMQ, Azure Queues, etc
• Offload long running and critical tasking
• Example: Twitter, Amazon
#20