IIS 6.0 and asp.net

13,250 views

Published on

Building Scalable And High Performance Web Applications on IIS 6.0 And ASP.NET

Published in: Technology
0 Comments
12 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
13,250
On SlideShare
0
From Embeds
0
Number of Embeds
528
Actions
Shares
0
Downloads
1
Comments
0
Likes
12
Embeds 0
No embeds

No notes for slide
  • IIS 6.0 and asp.net

    1. 1. Building Scalable And High Performance Web Applications on IIS 6.0 And ASP.NET Rishi Kothari
    2. 2. Agenda <ul><li>What is new in IIS 6.0 </li></ul><ul><li>ASP.NET Performance Tips & Tricks </li></ul>
    3. 3. Me.About() <ul><li>What do I do: </li></ul><ul><ul><li>U2U </li></ul></ul><ul><ul><ul><li>Training </li></ul></ul></ul><ul><ul><ul><ul><li>Standard Microsoft MOC curriculum </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Specialized Microsoft curriculum written by U2U </li></ul></ul></ul></ul><ul><ul><li>U2U.BIZ </li></ul></ul><ul><ul><ul><li>Coaching & Consultancy Services on the full range of Microsoft Development Tools </li></ul></ul></ul><ul><ul><ul><ul><li>.Net Development </li></ul></ul></ul></ul><ul><ul><ul><ul><li>SQL Server, SharePoint Portal Server, … </li></ul></ul></ul></ul><ul><ul><li>Microsoft Regional Director </li></ul></ul><ul><ul><ul><li>independent developers and architects chosen for their leadership in their local technology circles </li></ul></ul></ul>
    4. 4. After Windows Server 2003 installation Where is my Web Server ? <ul><li>This Windows Server 2003 thing doesn't work, let’s switch back to Windows 2000 </li></ul><ul><li>But wait: </li></ul><ul><ul><li>IIS 6.0 not installed by default </li></ul></ul><ul><ul><li>Once installed </li></ul></ul><ul><ul><ul><li>IIS 6.0 only serves static content by default </li></ul></ul></ul><ul><ul><ul><li>Security is much more locked down by default. </li></ul></ul></ul>
    5. 5. IIS 6.0 Architecture
    6. 6. Rearchitecting IIS Why do it - Current Challenges <ul><li>Availability – need 99.999% uptime </li></ul><ul><ul><li>Apps can still run in INETINFO on IIS5, which can affect web server reliability </li></ul></ul><ul><li>App isolation comes at a cost </li></ul><ul><ul><li>Perf vs. Reliability </li></ul></ul><ul><ul><li>Can’t isolate everything! </li></ul></ul><ul><li>IISRESET = Heavy Hammer </li></ul><ul><ul><li>Resets connections </li></ul></ul>
    7. 7. Rearchitecting IIS A review of IIS5 TCP/IP kernel user WinSock 2.0 DLLHost.EXE ISAPI Extensions DLLHost.EXE ISAPI Extensions INETINFO.EXE Metabase ISAPI Filters and Extensions DLLHost.EXE ISAPI Extensions INETINFO.EXE Metabase ISAPI Filters and Extensions
    8. 8. Rearchitecting IIS A New Architecture for IIS6 <ul><li>GOAL: enable complete app isolation from other web apps and core web server </li></ul><ul><li>Web service in INETINFO split out to do this: </li></ul><ul><ul><li>HTTP.SYS: kernel mode listener and request router </li></ul></ul><ul><ul><li>WAS: config and process manager </li></ul></ul><ul><ul><li>Worker Processes: where web apps are processed </li></ul></ul><ul><li>Multiple Worker Processes </li></ul>WAS Worker Processes web app HTTP.SYS kernel
    9. 9. Rearchitecting IIS HTTP.SYS <ul><li>What is it? </li></ul><ul><ul><li>Kernel-mode HTTP stack/listener </li></ul></ul><ul><ul><li>Always running </li></ul></ul><ul><ul><li>Supports listening on IPv4 and IPv6 protocols </li></ul></ul><ul><li>Reliability Features </li></ul><ul><ul><li>Doesn’t load or run any web apps including ISAPI filters and extensions </li></ul></ul><ul><ul><li>Process routing based on URL </li></ul></ul><ul><ul><li>Request queues: kernel-mode queuing </li></ul></ul><ul><li>Performance Features </li></ul><ul><ul><li>Kernel-mode response cache </li></ul></ul><ul><ul><li>Text-based and binary logging </li></ul></ul>
    10. 10. Rearchitecting IIS W3 Worker Processes– W3WP.exe <ul><li>What is it? </li></ul><ul><ul><li>Main web processing core responsible for handling web requests </li></ul></ul><ul><li>Self–contained web server </li></ul><ul><ul><li>Contains all web request processing functionality </li></ul></ul><ul><ul><li>Loads ISAPI’s – filters and extensions </li></ul></ul><ul><ul><ul><li>ASP, ASP .NET, FrontPage ® Server Extensions </li></ul></ul></ul><ul><li>Delivers complete isolation from system components and other web apps </li></ul>
    11. 11. Rearchitecting IIS Web Admin Service (WAS) <ul><li>Application Manager </li></ul><ul><ul><li>Manages lifetime of Worker Processes </li></ul></ul><ul><li>Configuration Manager </li></ul><ul><ul><li>Configures HTTP.SYS </li></ul></ul><ul><li>No application code </li></ul><ul><ul><li>Ensures web server reliability </li></ul></ul><ul><ul><li>External monitor of web application processes </li></ul></ul><ul><ul><li>Ensures web application and service reliability </li></ul></ul><ul><li>Hosted in SVCHOST.exe </li></ul><ul><ul><li>Actually part of W3SVC </li></ul></ul>
    12. 12. Process Model Contrast IIS5 to IIS6 – Making it more robust HTTP.SYS TCP/IP Connections Requests User Mode Kernel Mode WAS ASP.NET Filters Worker Process ASP.NET Filters Worker Process ASP.NET Filters Worker Process INETINFO metabase AppPool 1 AppPool 2
    13. 13. IIS 6.0 Availability Enhancements
    14. 14. Application Pools Application Isolation in Processes <ul><li>Can create 1 or more application pools </li></ul><ul><ul><li>Each served by 1 or more processes. </li></ul></ul><ul><ul><li>Each worker process serves only 1 pool. </li></ul></ul><ul><ul><li>Reqs routed directly to pool by HTTP.sys </li></ul></ul><ul><li>Isolate apps based on: </li></ul><ul><ul><li>Site/Customer </li></ul></ul><ul><ul><li>Functionality </li></ul></ul><ul><ul><li>Reliability </li></ul></ul>
    15. 15. Recycling What is it and Why use it? <ul><li>What is it? </li></ul><ul><ul><li>Periodically restart applications based on: </li></ul></ul><ul><ul><ul><li>Uptime </li></ul></ul></ul><ul><ul><ul><li># of requests </li></ul></ul></ul><ul><ul><ul><li>Scheduled time </li></ul></ul></ul><ul><ul><ul><li>Memory consumption </li></ul></ul></ul><ul><ul><ul><li>On-demand </li></ul></ul></ul><ul><li>Why use it? </li></ul><ul><ul><li>Refresh apps to ensure availability </li></ul></ul><ul><ul><li>Prevent bad apps from taking over the system </li></ul></ul><ul><li>No interruption in Service!! </li></ul>
    16. 16. Recycling Overlapping Recycle kernel user Ready for Recycle Shut down WAS HTTP.SYS Old Worker Process ISAPI Exts & Filters Web Proc. Core DLL New Worker Process ISAPI Exts & Filters Web Proc. Core DLL Request startup ready Request
    17. 17. Health Detection Crash Detection & Rapid Fail Protection <ul><li>WAS detects process crash/AV’s </li></ul><ul><li>On failure </li></ul><ul><ul><li>Publish event to event log </li></ul></ul><ul><ul><li>Check “crash count” </li></ul></ul><ul><ul><li>If (Crash count > Max Crashes in time limit) </li></ul></ul><ul><ul><ul><li>Disable app pool </li></ul></ul></ul><ul><ul><li>Else start new process if demand </li></ul></ul><ul><li>Rapid Fail Protection </li></ul><ul><ul><li>Only allow x crashes in y minutes </li></ul></ul><ul><ul><li>Return 503’s when invoked </li></ul></ul>
    18. 18. ASP.NET Best Practices
    19. 19. ASP.Net & Windows Server 2003 <ul><li>.Net Framework delivered in the box </li></ul><ul><li>ASP.NET will use the IIS6 process model when running in W3WP.exe </li></ul><ul><ul><li>Runs completely within W3WP.exe </li></ul></ul><ul><ul><li>Takes advantage of complete process isolation and added health/reliability features </li></ul></ul><ul><li>Store ASP.NET’s session state externally </li></ul><ul><ul><li>Persist state through a recycle </li></ul></ul>
    20. 20. Logical/Physical Design Best Practices
    21. 21. Logical Design <ul><li>Design your applications using logical 3-Tier Design Practices: </li></ul><ul><ul><li>Pages (.aspx) and User Controls (.ascx) </li></ul></ul><ul><ul><li>Reusable Biz & Data Classes in in dir (.vb + .cs) </li></ul></ul><ul><ul><li>Data within a SQL Database </li></ul></ul><ul><li>Design your Web application so that it can be distributed across a Web farm </li></ul><ul><ul><li>Your code shouldn’t assume that a client will always return to the same machine </li></ul></ul><ul><ul><li>Be careful of assumptions regarding statics and application state </li></ul></ul>
    22. 22. Physical Deployment <ul><li>Deploy your applications such that the pages and components run in same process </li></ul><ul><ul><li>Deploying onto remote servers connected via DCOM(COM+ Enterprise Services), Remoting or Web Services will almost always hurt your performance </li></ul></ul><ul><ul><li>Leverage Web services only for application to application communication -- not intra app calls </li></ul></ul>
    23. 23. 3 Tier Deployment Numbers
    24. 24. Server Control Performance Recommendations
    25. 25. Server Controls <ul><li>Server controls provide a very clean programming model abstraction </li></ul><ul><ul><li>Recommended way to build ASP.NET pages </li></ul></ul><ul><li>Server controls do more rendering/postback work that old-style <%= %> code </li></ul><ul><ul><li>Should understand what this work is and optimize for it accordingly </li></ul></ul><ul><li>Net take: the more individual server controls on page, the more this overhead can be noticed </li></ul><ul><ul><li>Need to be especially aware of this w/ composite list controls that generate multiple controls per data row </li></ul></ul>
    26. 26. Control Rendering Test
    27. 27. Caching Performance Best Practices
    28. 28. Design For Caching <ul><li>Cache, Cache, Cache – never do work you don’t need to do </li></ul><ul><li>Leverage the built-in ASP.NET built-in caching features </li></ul><ul><ul><li>Output Caching </li></ul></ul><ul><ul><li>Fragment Caching </li></ul></ul><ul><ul><li>Cache API </li></ul></ul><ul><li>Recommendation: </li></ul><ul><ul><li>Specifically design your pages around these features – can lead to massive perf wins </li></ul></ul>
    29. 29. Output Caching <ul><li>Caches the static result of an ASP.NET page </li></ul><ul><ul><li>Declarative <%@ OutputCache %> directive </li></ul></ul><ul><ul><li>Optional Output Cache APIs can also be called </li></ul></ul><ul><li>Caching Options: </li></ul><ul><ul><li>Duration </li></ul></ul><ul><ul><ul><li>Time item exists in the cache </li></ul></ul></ul><ul><ul><li>VaryByParam </li></ul></ul><ul><ul><ul><li>Varies cache entries by Get/Post params </li></ul></ul></ul><ul><ul><ul><li>Name param, separate by semi-colons, supports * </li></ul></ul></ul><ul><ul><li>VaryByHeader </li></ul></ul><ul><ul><ul><li>Varies cache entries by Http header </li></ul></ul></ul><ul><ul><li>VaryByCustom </li></ul></ul><ul><ul><ul><li>Override method within Global.asax to custom vary by whatever you want (you control the cache key) </li></ul></ul></ul>
    30. 30. Dynamic Kernel Caching GET http://www.acme.com/store/sproketcatalog.aspx Without Cache <%@ OutputCache Duration=&quot;10&quot; VaryByParam=&quot;none&quot; %> Request Response With Cache Request Response

    ×