ASP.NET Scalability - NxtGen Oxford

Phil Pursglove
Phil PursgloveSoftware Developer at WSP Group
“This One Goes Up To 11”
                              or
         How to write scalable ASP.NET

Phil Pursglove
phil@philippursglove.com
http://diaryofadotnetdeveloper.blogspot.com
http://www.philippursglove.com/ScalableASPNET
http://twitter.com/philpursglove
About Me
•   Senior .NET Developer
•   MBCS
•   MCSD
•   VBUG East Anglia Co-ordinator
•   Written for VB Developer and SQL
    Server Pro
Agenda
• Increasing server performance
  – Caching
     •   Output caching
     •   Object caching
     •   Donut caching
     •   Velocity
  – Paging
• Reducing network loads
  – Managing ViewState
  – Compression
• Load Balancing
What is Scalability?
• “The ability to handle growing amounts
  of work in a graceful manner” Wikipedia
• What affects scalability?

• Everything you see this evening
  applies to .NET 2.0 and higher
Increasing Server
  Performance
Why Cache?
• Because there’s a credit crunch!
• Building a page is an expensive
  process
  – Database calls across servers
  – Web Service calls
  – AD lookups

• Returning a stored page from a cache
  is much cheaper!
Caching 1: OutputCache
• Caches the rendered HTML from your
  page
  – Duration is in seconds
  – VaryByParam allows you to cache several
    versions
  – Location means you can cache on the
    web server, client, downstream machines
    or all of these
  – CacheProfiles mean you have fine config-
    based control
Caching 2: Caching API
• Store objects in memory and pull them
  out when you need them

• For data objects, you have to use
  DataSets and DataTables, not
  DataReaders
Caching 2: CacheDependency
• Objects in the cache can be dependent on
  other objects
  – When the dependency changes, the cached item
    is removed
  – Not very useful in .NET 1.1

• .NET 2.0 introduced SqlCacheDependency
  – Cached objects can be dependent on SQL tables
  – Enable using the ASPNET_REGSQL tool
  – Or programmatically with the
    SqlCacheDependencyAdmin object
Caching 3: Velocity
• Velocity
  – Distributed cache
     • One logical cache split across several servers
     • PowerShell management console
  – CTP2 released at PDC
  – CTP3 releasing at Mix 09

  – Doesn’t have dependencies – yet

  – The future: automatic caching?
Caching 3: Velocity
Caching 4: Donut Caching
• aka Post-Cache Substitution

• Inject dynamic content into a cached
  page before it is returned to the client
  – <asp:substitution>
  – Must use static methods with a
    HttpContext
Paging
• Default GridView paging behaviour reads the
  entire dataset every time
  – For 100 000 rows this probably isn’t so good
• Write your own paging mechanism
• For custom paging DataGrids are better than
  GridViews
• In SQL 2005 the ROW_NUMBER function is
  your friend!
• LINQ
  – Skip
Reducing Network Loads
ViewState 1
                                    Viewstate Size
                                       in bytes
   HTML Table (built in-line)            52
HTML Table (built in code-behind)        52
          DataList                      6628
         Repeater                       6600
          DataGrid                      10592
          GridView                      10928
ViewState 2
• Taming Viewstate
  – Can be disabled per-control
  – ZIP it up and put the zipped version on the
    page
  – Keep it on the web server
Compression 1
• All modern browsers will accept
  compressed content
     – Content is compressed on the server /
       decompressed by the browser
     – Can be enabled in IIS
or
     – Use the HttpCompress library
Compression
Compression 2
• JavaScript Compression
  – JSMin (http://tinyurl.com/jscriptmin)
  – jQuery is pre-minified for you


• CSS Compression
Load Balancing
Load Balancing
• Synchronise machineKey (in
  machine.config)
• Don’t use basic Session state
  – SQL Server Session State
  – ASP.NET State Service
  – Velocity ASP.NET Session state
Summary
• Cache is King!
• Paging is good for your pages!
• Viewstate doesn’t have to be evil!
Any Questions?
Resources
• DotNetRocks
  – http://www.dotnetrocks.com/default.aspx?showNum=24
  – http://www.dotnetrocks.com/default.aspx?showNum=367



• Books
  – Essential ASP.NET by Fritz Onion
  – The ASP.NET 2.0 Cookbook by Michael Gittel & Geoffrey
    LeBlond
  – The ASP.NET Anthology by Scott Allen et al


• MSDN White Paper on .NET Performance &
  Scalability
  – http://msdn.microsoft.com/en-us/library/ms998530.aspx
Resources
• Velocity
  – http://blogs.msdn.com/velocity
  – http://www.hanselman.com/blog/HanselminutesPodcast116DistributedCac
    hingWithMicrosoftsVelocity.aspx

• Donut Caching
  – http://tinyurl.com/donutcaching




• HttpCompress Library
  –   http://www.blowery.org/code/HttpCompressionModule.html
1 of 25

Recommended

ASP.NET Scalability - DDD7 by
ASP.NET Scalability - DDD7ASP.NET Scalability - DDD7
ASP.NET Scalability - DDD7Phil Pursglove
1.1K views25 slides
ASP.NET Scalability - WebDD by
ASP.NET Scalability - WebDDASP.NET Scalability - WebDD
ASP.NET Scalability - WebDDPhil Pursglove
999 views22 slides
ASP.NET Scalability - VBUG London by
ASP.NET Scalability - VBUG LondonASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonPhil Pursglove
544 views23 slides
Optimising for Performance by
Optimising for PerformanceOptimising for Performance
Optimising for Performancethomas_mb
494 views33 slides
Silverstripe at scale - design & architecture for silverstripe applications by
Silverstripe at scale - design & architecture for silverstripe applicationsSilverstripe at scale - design & architecture for silverstripe applications
Silverstripe at scale - design & architecture for silverstripe applicationsBrettTasker
61 views48 slides
Web Performance Part 3 "Server-side tips" by
Web Performance Part 3  "Server-side tips"Web Performance Part 3  "Server-side tips"
Web Performance Part 3 "Server-side tips"Binary Studio
1.2K views20 slides

More Related Content

What's hot

Insight on MongoDB Change Stream - Abhishek.D, Mydbops Team by
Insight on MongoDB Change Stream - Abhishek.D, Mydbops TeamInsight on MongoDB Change Stream - Abhishek.D, Mydbops Team
Insight on MongoDB Change Stream - Abhishek.D, Mydbops TeamMydbops
523 views37 slides
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011 by
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011camp_drupal_ua
1.2K views12 slides
Design a scalable site: Problem and solutions by
Design a scalable site: Problem and solutionsDesign a scalable site: Problem and solutions
Design a scalable site: Problem and solutionsChau Thanh
615 views32 slides
OpenCms Days 2014 - OpenCms cloud setup with the FI-TS by
OpenCms Days 2014 - OpenCms cloud setup with the FI-TSOpenCms Days 2014 - OpenCms cloud setup with the FI-TS
OpenCms Days 2014 - OpenCms cloud setup with the FI-TSAlkacon Software GmbH & Co. KG
1.1K views35 slides
WordPress at Scale Webinar by
WordPress at Scale WebinarWordPress at Scale Webinar
WordPress at Scale WebinarPantheon
1.8K views33 slides
Drupalcamp Estonia - High Performance Sites by
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sitesdrupalcampest
865 views18 slides

What's hot(16)

Insight on MongoDB Change Stream - Abhishek.D, Mydbops Team by Mydbops
Insight on MongoDB Change Stream - Abhishek.D, Mydbops TeamInsight on MongoDB Change Stream - Abhishek.D, Mydbops Team
Insight on MongoDB Change Stream - Abhishek.D, Mydbops Team
Mydbops523 views
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011 by camp_drupal_ua
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
camp_drupal_ua1.2K views
Design a scalable site: Problem and solutions by Chau Thanh
Design a scalable site: Problem and solutionsDesign a scalable site: Problem and solutions
Design a scalable site: Problem and solutions
Chau Thanh615 views
WordPress at Scale Webinar by Pantheon
WordPress at Scale WebinarWordPress at Scale Webinar
WordPress at Scale Webinar
Pantheon1.8K views
Drupalcamp Estonia - High Performance Sites by drupalcampest
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
drupalcampest865 views
WordCamp RVA 2011 - Performance & Tuning by Timothy Wood
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & Tuning
Timothy Wood796 views
MySQL Rebuild using Logical Backups by Mydbops
MySQL Rebuild using Logical Backups MySQL Rebuild using Logical Backups
MySQL Rebuild using Logical Backups
Mydbops209 views
Php & web server performace by Tuyển Đoàn
Php & web server performacePhp & web server performace
Php & web server performace
Tuyển Đoàn5.3K views
Евгений Самоненко - Практическая оптимизация сервер сайд современные реалии by Web Tech Fun
Евгений Самоненко - Практическая оптимизация сервер сайд современные реалииЕвгений Самоненко - Практическая оптимизация сервер сайд современные реалии
Евгений Самоненко - Практическая оптимизация сервер сайд современные реалии
Web Tech Fun 54 views
Практическая оптимизация сервер сайд: современные реалии by Valtech Ukraine
Практическая оптимизация сервер сайд: современные реалииПрактическая оптимизация сервер сайд: современные реалии
Практическая оптимизация сервер сайд: современные реалии
Valtech Ukraine66 views
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016 by Dylan Butler
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Dylan Butler484 views
Full stack development using javascript what and why - ajay chandravadiya by ajayrcgmail
Full stack development using javascript   what and why - ajay chandravadiyaFull stack development using javascript   what and why - ajay chandravadiya
Full stack development using javascript what and why - ajay chandravadiya
ajayrcgmail286 views

Viewers also liked

Crystal MEF by
Crystal MEFCrystal MEF
Crystal MEFPhil Pursglove
695 views10 slides
παρουσιαση προϊοντοσ με Dvd by
παρουσιαση προϊοντοσ με Dvdπαρουσιαση προϊοντοσ με Dvd
παρουσιαση προϊοντοσ με DvdPeaca and Glory
187 views97 slides
Velocity - Edge UG by
Velocity - Edge UGVelocity - Edge UG
Velocity - Edge UGPhil Pursglove
377 views16 slides
Remembering Amber by
Remembering  AmberRemembering  Amber
Remembering AmberHolly.Cairell
283 views73 slides
The Need For Speed - NEBytes by
The Need For Speed - NEBytesThe Need For Speed - NEBytes
The Need For Speed - NEBytesPhil Pursglove
335 views17 slides
The Need For Speed - NxtGen Cambridge by
The Need For Speed - NxtGen CambridgeThe Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen CambridgePhil Pursglove
413 views19 slides

Viewers also liked(9)

παρουσιαση προϊοντοσ με Dvd by Peaca and Glory
παρουσιαση προϊοντοσ με Dvdπαρουσιαση προϊοντοσ με Dvd
παρουσιαση προϊοντοσ με Dvd
Peaca and Glory187 views
The Need For Speed - NEBytes by Phil Pursglove
The Need For Speed - NEBytesThe Need For Speed - NEBytes
The Need For Speed - NEBytes
Phil Pursglove335 views
The Need For Speed - NxtGen Cambridge by Phil Pursglove
The Need For Speed - NxtGen CambridgeThe Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen Cambridge
Phil Pursglove413 views
Tweet reach its_k_isabella by Matthew Gain
Tweet reach its_k_isabellaTweet reach its_k_isabella
Tweet reach its_k_isabella
Matthew Gain2.4K views
Twitter and the Australian Election 2010 by Matthew Gain
Twitter and the Australian Election 2010Twitter and the Australian Election 2010
Twitter and the Australian Election 2010
Matthew Gain796 views

Similar to ASP.NET Scalability - NxtGen Oxford

DrupalSouth 2015 - Performance: Not an Afterthought by
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtNick Santamaria
377 views44 slides
Optimizing Your Frontend Performance by
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend PerformanceThomas Weinert
1K views47 slides
Scylla Summit 2016: Compose on Containing the Database by
Scylla Summit 2016: Compose on Containing the DatabaseScylla Summit 2016: Compose on Containing the Database
Scylla Summit 2016: Compose on Containing the DatabaseScyllaDB
2K views35 slides
Website optimization with request reduce by
Website optimization with request reduceWebsite optimization with request reduce
Website optimization with request reduceMatt Wrock
2.8K views26 slides
High performance website by
High performance websiteHigh performance website
High performance websiteChamnap Chhorn
5.9K views53 slides
How_To_Soup_Up_Your_Farm by
How_To_Soup_Up_Your_FarmHow_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_FarmNigel Price
84 views32 slides

Similar to ASP.NET Scalability - NxtGen Oxford(20)

DrupalSouth 2015 - Performance: Not an Afterthought by Nick Santamaria
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
Nick Santamaria377 views
Optimizing Your Frontend Performance by Thomas Weinert
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
Thomas Weinert1K views
Scylla Summit 2016: Compose on Containing the Database by ScyllaDB
Scylla Summit 2016: Compose on Containing the DatabaseScylla Summit 2016: Compose on Containing the Database
Scylla Summit 2016: Compose on Containing the Database
ScyllaDB2K views
Website optimization with request reduce by Matt Wrock
Website optimization with request reduceWebsite optimization with request reduce
Website optimization with request reduce
Matt Wrock2.8K views
How_To_Soup_Up_Your_Farm by Nigel Price
How_To_Soup_Up_Your_FarmHow_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_Farm
Nigel Price84 views
Biomatters and Amazon Web Services by Biomatters
Biomatters and Amazon Web Services Biomatters and Amazon Web Services
Biomatters and Amazon Web Services
Biomatters584 views
Architectures, Frameworks and Infrastructure by harendra_pathak
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
harendra_pathak464 views
Apache Performance Tuning: Scaling Out by Sander Temme
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling Out
Sander Temme7.8K views
Rails Caching: Secrets From the Edge by Fastly
Rails Caching: Secrets From the EdgeRails Caching: Secrets From the Edge
Rails Caching: Secrets From the Edge
Fastly2.6K views
Rails Caching Secrets from the Edge by Michael May
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the Edge
Michael May1.7K views
[Hanoi-August 13] Tech Talk on Caching Solutions by ITviec
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions
ITviec2.6K views
Webpack and Web Performance Optimization by Chen-Tien Tsai
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
Chen-Tien Tsai1.5K views
More Cache for Less Cash (DevLink 2014) by Michael Collier
More Cache for Less Cash (DevLink 2014)More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)
Michael Collier8K views
SharePoint Saturday San Antonio: SharePoint 2010 Performance by Brian Culver
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceSharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 Performance
Brian Culver805 views
Speeding Up The Snail by Marcus Deglos
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The Snail
Marcus Deglos1.4K views

Recently uploaded

Serverless computing with Google Cloud (2023-24) by
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)wesley chun
11 views33 slides
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...Jasper Oosterveld
18 views49 slides
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdfDr. Jimmy Schwarzkopf
19 views29 slides
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensorssugiuralab
19 views15 slides
Zero to Automated in Under a Year by
Zero to Automated in Under a YearZero to Automated in Under a Year
Zero to Automated in Under a YearNetwork Automation Forum
15 views23 slides
Kyo - Functional Scala 2023.pdf by
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdfFlavio W. Brasil
368 views92 slides

Recently uploaded(20)

Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab19 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada127 views
Empathic Computing: Delivering the Potential of the Metaverse by Mark Billinghurst
Empathic Computing: Delivering  the Potential of the MetaverseEmpathic Computing: Delivering  the Potential of the Metaverse
Empathic Computing: Delivering the Potential of the Metaverse
Mark Billinghurst478 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely21 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi127 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院

ASP.NET Scalability - NxtGen Oxford

  • 1. “This One Goes Up To 11” or How to write scalable ASP.NET Phil Pursglove phil@philippursglove.com http://diaryofadotnetdeveloper.blogspot.com http://www.philippursglove.com/ScalableASPNET http://twitter.com/philpursglove
  • 2. About Me • Senior .NET Developer • MBCS • MCSD • VBUG East Anglia Co-ordinator • Written for VB Developer and SQL Server Pro
  • 3. Agenda • Increasing server performance – Caching • Output caching • Object caching • Donut caching • Velocity – Paging • Reducing network loads – Managing ViewState – Compression • Load Balancing
  • 4. What is Scalability? • “The ability to handle growing amounts of work in a graceful manner” Wikipedia • What affects scalability? • Everything you see this evening applies to .NET 2.0 and higher
  • 5. Increasing Server Performance
  • 6. Why Cache? • Because there’s a credit crunch! • Building a page is an expensive process – Database calls across servers – Web Service calls – AD lookups • Returning a stored page from a cache is much cheaper!
  • 7. Caching 1: OutputCache • Caches the rendered HTML from your page – Duration is in seconds – VaryByParam allows you to cache several versions – Location means you can cache on the web server, client, downstream machines or all of these – CacheProfiles mean you have fine config- based control
  • 8. Caching 2: Caching API • Store objects in memory and pull them out when you need them • For data objects, you have to use DataSets and DataTables, not DataReaders
  • 9. Caching 2: CacheDependency • Objects in the cache can be dependent on other objects – When the dependency changes, the cached item is removed – Not very useful in .NET 1.1 • .NET 2.0 introduced SqlCacheDependency – Cached objects can be dependent on SQL tables – Enable using the ASPNET_REGSQL tool – Or programmatically with the SqlCacheDependencyAdmin object
  • 10. Caching 3: Velocity • Velocity – Distributed cache • One logical cache split across several servers • PowerShell management console – CTP2 released at PDC – CTP3 releasing at Mix 09 – Doesn’t have dependencies – yet – The future: automatic caching?
  • 12. Caching 4: Donut Caching • aka Post-Cache Substitution • Inject dynamic content into a cached page before it is returned to the client – <asp:substitution> – Must use static methods with a HttpContext
  • 13. Paging • Default GridView paging behaviour reads the entire dataset every time – For 100 000 rows this probably isn’t so good • Write your own paging mechanism • For custom paging DataGrids are better than GridViews • In SQL 2005 the ROW_NUMBER function is your friend! • LINQ – Skip
  • 15. ViewState 1 Viewstate Size in bytes HTML Table (built in-line) 52 HTML Table (built in code-behind) 52 DataList 6628 Repeater 6600 DataGrid 10592 GridView 10928
  • 16. ViewState 2 • Taming Viewstate – Can be disabled per-control – ZIP it up and put the zipped version on the page – Keep it on the web server
  • 17. Compression 1 • All modern browsers will accept compressed content – Content is compressed on the server / decompressed by the browser – Can be enabled in IIS or – Use the HttpCompress library
  • 19. Compression 2 • JavaScript Compression – JSMin (http://tinyurl.com/jscriptmin) – jQuery is pre-minified for you • CSS Compression
  • 21. Load Balancing • Synchronise machineKey (in machine.config) • Don’t use basic Session state – SQL Server Session State – ASP.NET State Service – Velocity ASP.NET Session state
  • 22. Summary • Cache is King! • Paging is good for your pages! • Viewstate doesn’t have to be evil!
  • 24. Resources • DotNetRocks – http://www.dotnetrocks.com/default.aspx?showNum=24 – http://www.dotnetrocks.com/default.aspx?showNum=367 • Books – Essential ASP.NET by Fritz Onion – The ASP.NET 2.0 Cookbook by Michael Gittel & Geoffrey LeBlond – The ASP.NET Anthology by Scott Allen et al • MSDN White Paper on .NET Performance & Scalability – http://msdn.microsoft.com/en-us/library/ms998530.aspx
  • 25. Resources • Velocity – http://blogs.msdn.com/velocity – http://www.hanselman.com/blog/HanselminutesPodcast116DistributedCac hingWithMicrosoftsVelocity.aspx • Donut Caching – http://tinyurl.com/donutcaching • HttpCompress Library – http://www.blowery.org/code/HttpCompressionModule.html