DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)
Transcript of DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)
How to speed up .NET and SQL Server web
appsBart Read
Who am I?• Bart Read, Web, Database, and Mobile Performance Consultant• Previously worked for Red Gate• Contacts• E: [email protected]• W: www.bartread.com• B: www.bartread.com/blog• T: @bart_read• GH: https://github.com/bartread
General Web Performance
http://www.bartread.com/2014/06/03/web-performance-how-fast-does-website-need-to-be/
Always measure! (But
it’s almost never the
code!)
Production Monitoring
Detailed Diagnostic Tools
Other Handy Ancillary Tools
A word of warning about SSMS
Read Erland Sommarskog’s post, “Slow in the application, fast in SSMS?”: http://www.sommarskog.se/query-plan-mysteries.html
Scenario 1The Slow Support Centre
Customer Support Centre
(MS Dynamics)
Grant Fritchey’s FREE eBook on execution plans:
http://www.red-gate.com/community/books/sql-server-execution-plans-ed-2
Tool: http://www.supratimas.com/
Scenario 2The Memory Leak in the eCommerce Site
eCommerce Site
(MS Dynamics)
Other technologies:- NServiceBus- Endeca
Scenario 3Locking, Blocking and Deadlocking
Locking, Blocking & Deadlocking
Concurrency• Object level concurrency• Row level concurrency
Transaction Isolation Levels• Read Uncommitted• Read Committed <- SQL Server default• Repeatable Read• Snapshot• Serializable
ACID
Locking pattern• Reads• A -> B -> C -> D -> A -> B -> C -> D -> E -> A …• Etc.
• Writes• A –> B -> C -> D -> E -> A -> B -> A -> B -> C -> D …• Etc.
Solutions• DEADLOCK_PRIORITY• http://msdn.microsoft.com/en-us/library/ms186736.aspx• SET DEADLOCK_PRIORITY LOW | NORMAL | HIGH
• Read Committed Snapshot Isolation• http://www.brentozar.com/archive/2013/01/implementing-snapshot-or-read-
committed-snapshot-isolation-in-sql-server-a-guide/
• Disciplined ordering of object access• Unit of Work Pattern
• Martin Fowler• http://martinfowler.com/eaaCatalog/unitOfWork.html
Scenario 4Networking
Stuart Cheshire, “It’s the latency, stupid” (1996): http://www.stuartcheshire.org/rants/latency.html
Fast/Slow Query
Query Frame
Result Set Frame
Virtual NIC Setting To Blame
Client-side Scenarios - General Observations• Payload• Chattiness/latency• CSS transitions and animations• Code execution time again becomes an issue• Garbage• High memory usage
Star Citadel: https://arcade.ly/games/starcastle
Other Scenarios• Indexes• Missing indexes• Maintenance• Statistics• NTEXT (etc.) preventing online rebuilds
• http://www.bartread.com/2014/09/17/convert-all-ntext-columns-to-nvarcharmax-sql-server/
• Stored procedures and cached execution plans• WITH RECOMPILE
Questions?E: [email protected]: www.bartread.comB: www.bartread.com/blogT: @bart_readGH: https://github.com/bartread
Red Gate coding challenge: http://www.red-gate.com/our-company/entrypage/coding-challenge