SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
“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

Weitere ähnliche Inhalte

Was ist angesagt?

Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
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_ua
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
drupalcampest
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
Php & web server performace
Php & web server performacePhp & web server performace
Php & web server performace
Tuyển Đoàn
 

Was ist angesagt? (16)

Insight on MongoDB Change Stream - Abhishek.D, Mydbops Team
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
 
Pankov Artem.Improving drupal performance www.hr portal.ru.DrupalCamp Kyiv 2011
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
 
Design a scalable site: Problem and solutions
Design a scalable site: Problem and solutionsDesign a scalable site: Problem and solutions
Design a scalable site: Problem and solutions
 
OpenCms Days 2014 - OpenCms cloud setup with the FI-TS
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-TS
 
WordPress at Scale Webinar
WordPress at Scale WebinarWordPress at Scale Webinar
WordPress at Scale Webinar
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
WordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & Tuning
 
Performance Web
Performance WebPerformance Web
Performance Web
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
MySQL Rebuild using Logical Backups
MySQL Rebuild using Logical Backups MySQL Rebuild using Logical Backups
MySQL Rebuild using Logical Backups
 
Php & web server performace
Php & web server performacePhp & web server performace
Php & web server performace
 
Евгений Самоненко - Практическая оптимизация сервер сайд современные реалии
Евгений Самоненко - Практическая оптимизация сервер сайд современные реалииЕвгений Самоненко - Практическая оптимизация сервер сайд современные реалии
Евгений Самоненко - Практическая оптимизация сервер сайд современные реалии
 
Практическая оптимизация сервер сайд: современные реалии
Практическая оптимизация сервер сайд: современные реалииПрактическая оптимизация сервер сайд: современные реалии
Практическая оптимизация сервер сайд: современные реалии
 
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
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
 
Presentation1
Presentation1Presentation1
Presentation1
 
Full stack development using javascript what and why - ajay chandravadiya
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
 

Andere mochten auch (9)

Crystal MEF
Crystal MEFCrystal MEF
Crystal MEF
 
παρουσιαση προϊοντοσ με Dvd
παρουσιαση προϊοντοσ με Dvdπαρουσιαση προϊοντοσ με Dvd
παρουσιαση προϊοντοσ με Dvd
 
Velocity - Edge UG
Velocity - Edge UGVelocity - Edge UG
Velocity - Edge UG
 
Remembering Amber
Remembering  AmberRemembering  Amber
Remembering Amber
 
The Need For Speed - NEBytes
The Need For Speed - NEBytesThe Need For Speed - NEBytes
The Need For Speed - NEBytes
 
The Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen CambridgeThe Need For Speed - NxtGen Cambridge
The Need For Speed - NxtGen Cambridge
 
Tweet reach its_k_isabella
Tweet reach its_k_isabellaTweet reach its_k_isabella
Tweet reach its_k_isabella
 
Twitter and the Australian Election 2010
Twitter and the Australian Election 2010Twitter and the Australian Election 2010
Twitter and the Australian Election 2010
 
What Genre Am I
What Genre Am IWhat Genre Am I
What Genre Am I
 

Ähnlich wie ASP.NET Scalability - NxtGen Oxford

Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
Thomas Weinert
 
High performance website
High performance websiteHigh performance website
High performance website
Chamnap Chhorn
 
How_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_FarmHow_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_Farm
Nigel Price
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
harendra_pathak
 

Ähnlich wie ASP.NET Scalability - NxtGen Oxford (20)

DrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an AfterthoughtDrupalSouth 2015 - Performance: Not an Afterthought
DrupalSouth 2015 - Performance: Not an Afterthought
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
Scylla Summit 2016: Compose on Containing the Database
Scylla Summit 2016: Compose on Containing the DatabaseScylla Summit 2016: Compose on Containing the Database
Scylla Summit 2016: Compose on Containing the Database
 
Website optimization with request reduce
Website optimization with request reduceWebsite optimization with request reduce
Website optimization with request reduce
 
High performance website
High performance websiteHigh performance website
High performance website
 
How_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_FarmHow_To_Soup_Up_Your_Farm
How_To_Soup_Up_Your_Farm
 
Biomatters and Amazon Web Services
Biomatters and Amazon Web Services Biomatters and Amazon Web Services
Biomatters and Amazon Web Services
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
Apache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling OutApache Performance Tuning: Scaling Out
Apache Performance Tuning: Scaling Out
 
Rails Caching: Secrets From the Edge
Rails Caching: Secrets From the EdgeRails Caching: Secrets From the Edge
Rails Caching: Secrets From the Edge
 
Rails Caching Secrets from the Edge
Rails Caching Secrets from the EdgeRails Caching Secrets from the Edge
Rails Caching Secrets from the Edge
 
Running PostgreSQL in a Kubernetes cluster: CloudNativePG
Running PostgreSQL in a Kubernetes cluster: CloudNativePGRunning PostgreSQL in a Kubernetes cluster: CloudNativePG
Running PostgreSQL in a Kubernetes cluster: CloudNativePG
 
[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions[Hanoi-August 13] Tech Talk on Caching Solutions
[Hanoi-August 13] Tech Talk on Caching Solutions
 
Webpack and Web Performance Optimization
Webpack and Web Performance OptimizationWebpack and Web Performance Optimization
Webpack and Web Performance Optimization
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)More Cache for Less Cash (DevLink 2014)
More Cache for Less Cash (DevLink 2014)
 
Performance out
Performance outPerformance out
Performance out
 
SharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceSharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 Performance
 
Speeding Up The Snail
Speeding Up The SnailSpeeding Up The Snail
Speeding Up The Snail
 
Mini-Training: To cache or not to cache
Mini-Training: To cache or not to cacheMini-Training: To cache or not to cache
Mini-Training: To cache or not to cache
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

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