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)
![Page 1: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/1.jpg)
How to speed up .NET and SQL Server web
appsBart Read
![Page 2: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/2.jpg)
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
![Page 3: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/3.jpg)
General Web Performance
http://www.bartread.com/2014/06/03/web-performance-how-fast-does-website-need-to-be/
![Page 4: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/4.jpg)
Always measure! (But
it’s almost never the
code!)
![Page 5: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/5.jpg)
Production Monitoring
![Page 6: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/6.jpg)
Detailed Diagnostic Tools
![Page 7: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/7.jpg)
Other Handy Ancillary Tools
![Page 8: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/8.jpg)
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
![Page 9: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/9.jpg)
Scenario 1The Slow Support Centre
![Page 10: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/10.jpg)
Customer Support Centre
(MS Dynamics)
![Page 11: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/11.jpg)
![Page 12: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/12.jpg)
![Page 13: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/13.jpg)
![Page 14: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/14.jpg)
![Page 15: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/15.jpg)
![Page 16: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/16.jpg)
![Page 17: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/17.jpg)
![Page 18: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/18.jpg)
![Page 19: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/19.jpg)
![Page 20: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/20.jpg)
![Page 21: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/21.jpg)
![Page 22: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/22.jpg)
![Page 23: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/23.jpg)
![Page 24: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/24.jpg)
![Page 25: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/25.jpg)
![Page 26: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/26.jpg)
![Page 27: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/27.jpg)
![Page 28: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/28.jpg)
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/
![Page 29: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/29.jpg)
![Page 30: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/30.jpg)
![Page 31: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/31.jpg)
![Page 32: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/32.jpg)
Scenario 2The Memory Leak in the eCommerce Site
![Page 33: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/33.jpg)
eCommerce Site
(MS Dynamics)
Other technologies:- NServiceBus- Endeca
![Page 34: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/34.jpg)
![Page 35: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/35.jpg)
![Page 36: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/36.jpg)
![Page 37: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/37.jpg)
![Page 38: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/38.jpg)
![Page 39: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/39.jpg)
![Page 40: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/40.jpg)
Scenario 3Locking, Blocking and Deadlocking
![Page 41: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/41.jpg)
Locking, Blocking & Deadlocking
![Page 42: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/42.jpg)
![Page 43: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/43.jpg)
Concurrency• Object level concurrency• Row level concurrency
![Page 44: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/44.jpg)
![Page 45: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/45.jpg)
Transaction Isolation Levels• Read Uncommitted• Read Committed <- SQL Server default• Repeatable Read• Snapshot• Serializable
ACID
![Page 46: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/46.jpg)
![Page 47: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/47.jpg)
![Page 48: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/48.jpg)
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.
![Page 49: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/49.jpg)
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
![Page 50: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/50.jpg)
Scenario 4Networking
Stuart Cheshire, “It’s the latency, stupid” (1996): http://www.stuartcheshire.org/rants/latency.html
![Page 51: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/51.jpg)
Fast/Slow Query
![Page 52: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/52.jpg)
![Page 53: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/53.jpg)
![Page 54: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/54.jpg)
![Page 55: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/55.jpg)
Query Frame
![Page 56: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/56.jpg)
Result Set Frame
![Page 57: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/57.jpg)
Virtual NIC Setting To Blame
![Page 58: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/58.jpg)
Client-side Scenarios - General Observations• Payload• Chattiness/latency• CSS transitions and animations• Code execution time again becomes an issue• Garbage• High memory usage
![Page 59: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/59.jpg)
Star Citadel: https://arcade.ly/games/starcastle
![Page 60: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/60.jpg)
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
![Page 61: DDD 2016: How to speed up .NET and SQL Server web apps (Reading, UK)](https://reader036.fdocuments.in/reader036/viewer/2022070509/58a31bf81a28ab1d068b662f/html5/thumbnails/61.jpg)
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