1 / 110

Web application Performance

Web application Performance.  Mark Friedman Architect Developer Division Microsoft Corporation. Web Application Performance. Agenda: ASP.NET architecture for building dynamic web applications Building scalable web applications Persisting Session state Caching application data

beth
Download Presentation

Web application Performance

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web application Performance  Mark Friedman Architect Developer Division Microsoft Corporation

  2. Web Application Performance • Agenda: • ASP.NET architecture for building dynamic web applications • Building scalable web applications • Persisting Session state • Caching application data • n-Tiered application scaling • Building responsive web applications • Page Load Time and Round trips • AJAX • Tips for Silverlight and WPF-based applications

  3. ASP.NET Application Performance • Framework for developing web sites that generate Dynamic HTML Responses • Get Request ↔ Response message • Additional files are frequently embedded in the Response HTML • e.g., <A HREF="resumepage.html">my resume</A> • Web Browser (e.g., IE) performs HTML layout • Frames • Tables • Images • Cascading Style Sheets <LINK REL=STYLESHEETHREF="mystyles.css" TYPE="text/css">

  4. ASP.NET Application Performance • From Web Pages to Web Applications • aka, Rich Internet Applications (RIA) • Dynamic HTML (Server-side processing) • SOAP (Web services) • AJAX (Client-side scripting) • Silverlight (Client-side runtime) • XAML elements (WPF) • etc., • Dynamic HTML is layered on top of the HTTP protocol, which was originally designed to be both connectionless and sessionless. • Individual requests are independent of each other • No “state” is preserved between one request and another

  5. ASP.NET Application Performance • Server-side Request processing • Event-oriented programming model (Postback) • HttpContext wrapper around the HTTP Request • Persistent State • ViewState • Session State • Application and Page Cache objects • etc.

  6. ASP.NET Application Performance • Client-side scripting • Rich Internet Applications (RIA) • AJAX • Browser Document Object Model (DOM) • Javascript • Asynchronous server Postbacks (to web services)

  7. ASP.NET Application Performance • Measurement considerations • On the client • Performance counters • Network Monitor traces • ETW traces (IE, etc.) • Direct measurements inside Javascript code • On the server • IIS logs (especially Time-Taken fields) • Performance counters • web app response time data is not available • ETW traces (IIS, ASP.NET, CLR, etc.) • volume considerations • Direct measurement inside .NET code • e.g., Stopwatch

  8. ASP.NET Application Performance • Measurement considerations • End-to-End • Multiple tiers

  9. Web Application Performance • HTTP application performance is constrained by network latency! Client-side script Network Latency Client-side script Client-side script Network Latency Network Latency Server-side .aspx Server-side .aspx Server-side .aspx Unit Test Load Test e.g., VS TeamTest Production

  10. Web Application Performance • Measuring Page Load Time • Time to First Byte • Network Monitor capture data • DNS Lookup • TCP Session handshaking • SYN, SYN-ACK, ACK sequence • Calculates 1st Round Trip Time used by Fast Retransmit logic • Dynamic HTML Response message generated by the ASP.NET application • Which can then reference additional files embedded in the HTML • e.g., css, js, jpg, gif, xml, xaml, wmv, etc. • When is the application Ready to use?

  11. ASP.NET Application Performance

  12. Web Application Performance

  13. demo Visual Roundtrip Analyzer

  14. Web Application Performance • VRTA (Visual Round Trip Analyzer)

  15. Web Application Performance • Elements of Page Load Time • Html • CSS • Javascript (serializes) • XAML • Images • Audio • Video • Banner ads (often from 3rd parties) • etc. • Page Load parallelism • IE7 limited to two parallel sessions • IE8 and Chrome support six parallel sessions

  16. Web Application Performance • Pages are assembled from a variety of elements, some of which may reside on different web servers • Static content can be cached: • on the client • on the server • somewhere in-between • Proxy servers • Cache engines • etc. • Semi-dynamic content may also be cacheable

  17. Web Application Performance • Semi-dynamic content generated by ASP.NET server-side code may be cacheable • Multiple facilities in IIS/ASP.NET available for caching • IIS kernel mode Cache • ASP.NET Application cache • ASP.NET Page cache • Virtual memory constraints relieved in x64 OS! • Note: these are complex facilities that may require considerable monitoring & analysis to achieve optimal results.

  18. Web Application Performance • Cache performance and efficiency • Caching is ubiquitous across the web • In the Browser • in the content delivery network infrastructure, • on the proxy server • on the web server (in multiple forms) • on the database server • For the sake of latency, cache data as close to the client as possible • Multiple layers of cache hold largely redundant data • One effective layer is usually sufficient • See “Caching Architecture Guide for .NET Framework Applications”

  19. ASP.NET Application Architecture w3wp.exe CommonLanguage Runtime (CLR) JIT compiler Garbage Collection threads mscoree.dll mscorsvr.dll MyApp.dll

  20. ASP.NET programming model • Event-driven programming (runat=“server”) Form: <asp:DropDownList id="FileDropDownList" style="Z-INDEX: 111; LEFT: 192px; POSITION: absolute; TOP: 240px“ runat="server" Width="552px" Height="40px“ AutoPostBack="True"></asp:DropDownList> Code behind: Private Sub FileDropDownList_SelectedIndexChanged _ (ByVal sender As System.Object, _ ByVale As System.EventArgs) _ Handles FileDropDownList.SelectedIndexChanged Session("FileSelected") = FileDropDownList.SelectedValue End Sub

  21. IIS Architecture HTTP Request

  22. IIS Architecture • Kernel mode driver (http.sys) • Dedicated kernel mode Response object cache • Static (jpgs, gifs, etc.) and semi-dynamic (ASP.NET) content • Accessed using Physical addresses only! • Monitor Web Service Cache\Kernel: Current URIs Cached, etc. See “IIS 7.0 Output Caching” at http://learn.iis.net/page.aspx/154/iis-7-output-caching/

  23. IIS Architecture • ASP and ASP.NET requests processed by w3wp.exe worker processes • Worker processes are configured intoApplication Pools managed by the Windows Process Activation Service (WAS) • Pool Health options (including automatic recycling) • Pool Performance options

  24. IIS Architecture • ASP.NET w3wp.exe worker processes Health monitoring • Performance counters per worker process in IIS 7.0 From a command line: \windows\system32\inetsrv\appcmd list WP

  25. demo Monitoring IIS worker processes

  26. Monitoring IIS worker processes

  27. Monitoring IIS worker processes

  28. IIS 7.0 Integrated Pipeline • ASP.NET services can be made available to non-ASP.NET applications! • ApplicationManager • HostingEnvironment • Per Request • HttpContext • HttpRequest • HttpResponse

  29. IIS 7.0 Integrated Mode • HttpApplication Event Handlers (IHttpModule)

  30. IIS 7.0 Integrated Mode • Leverage ASP.NET Modules (services) • FormsAuthenticationModule • ProfileModule • RoleManagerModule • SessionStateModule • See ApplicationHost.config<modules> section • See Mike Volodarsky, • “Explore The Web Server For Windows Vista And Beyond,” MSDN Magazine, March 2007 • “Enhance Your Apps with the Integrated ASP.NET Pipeline,” MSDN Magazine, January 2008. • “Build Web Server Solutions with End-to-End Extensibility,” MSDN Magazine, March 2008.

  31. demo Configure IIS ETW tracing to gather RequestNotification events  Mark Friedman Architect Developer Division

  32. Configure IIS Tracing using Logman • IIS: WWW Server Event Trace Provider

  33. Configure IIS Tracing using Logman • IIS: WWW Server Event Trace Provider Keywords

  34. Configure IIS Tracing using Logman • IIS: WWW Server Event Trace Provider – Level = 5 (Diagnostic level)

  35. ETW Trace reporting tools • Post-process etl Trace using • tracerpt tracerptfilename.etl –of CSV –o mytrace.csv • logparser logparser "select * from filename.etl" -e 20 -o:DATAGRID -rtp 30 -compactModeSep "|" • xperf

  36. ETW Trace reporting tools

  37. ETW Trace reporting tools

  38. Configure IIS Tracing using Logman • IIS: WWW Server Event Trace Provider Keywords • e.g., UseUrlFilterto control the volume of data • Configure the TraceUriPrefixMetabase Property See “How to Trace Requests for a Specific URL or Set of URLs” at http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/c56d19af-b3d1-4be9-8a6f-4aa86bacac3f.mspx?mfr=true

  39. ASP.NET programming model • The HTTP protocol is • connectionless • sessionless • .NET wrappers for HTTP protocol services • HttpContext • Provides programmatic access to all properties associated with an HTTP Request • Request • Response • Session • Cache

  40. ASP.NET programming model • .NET wrappers for HTTP protocol services • HttpContext.Request • HttpMethod(GET, POST, etc.) • URL • Cookiescollection • Headers • InputStream • UserHostAddress(IP address of the Requestor) • etc. • The ASP.NET programming model provides several facilities to persist User/Application state

  41. ASP.NET Page Events

  42. ASP.NET scalability strategies • Session State management • ASP.NET Cache • n-Tiered applications • e.g., • Presentation Layer • Business Logic Layer • Data Layer

  43. ASP.NET State Management • What is State? • Any information about the user, his/her history and association with the application that informs the application’s processing. • e.g., • how to associate a (potential) customer with his/her shopping cart?

  44. ASP.NET State Management • Session State management • Client-side options • Hidden fields • Cookies • Query strings (including Web Beacons or Clear GIFs ) • View state • Control state • Server-side options • Application state (HttpApplicationState) • Session state • Profile Properties

  45. ASP.NET State Management • State by Scope: • Applicationstate(HttpApplicationState) • Page • Static variables • potentially use Page.Cache for dynamic data • Session • Client-side options • Query strings • Cookies • Hidden fields • View state • Control state • Server-side options • Session state • Profile Properties

  46. ASP.NET Application Performance • Persisting state • on the client • on the server

  47. ASP.NET Application Performance • Persisting state on the server (ViewState) • Control ViewState (e.g., a DataGrid control) • View state is enabled for all server controls by default. • Additional round trips to the server may be required to re-send the Control’s ViewState • remember, the HTTP protocol is sessionless • Set the control's EnableViewState property to false to disable… • Or, use AJAX functions to eliminate server postbacks so you can maintain ViewState on the client (browser)

  48. demo Inspectingcontrols ViewState

  49. ASP.NET ViewState • ViewState • Passed to the client in _ViewState hidden field in the Response message • Returned to the Server on a postback Request • Inspect using • %@ Page Trace="true“ • View html Source on the client • 3rd party tools like Fiddler • Be careful of • Data bound controls (GridView, etc.) • Large TreeViews, DropDownLists, etc.

More Related