ASP.NET Architecture Internals Mike Shaw Developer & Platform Group Microsoft Ltd.

Slides:



Advertisements
Similar presentations
Internet Information Server 6.0. IIS 6.0 Enhancements  Fundamental changes, aimed at: Reliability & Availability Reliability & Availability Performance.
Advertisements

11 ASP.NET Slides based off:. 22 B ACKGROUND - W EB A RCHITECTURE Web Server PC/Mac/Unix/... + Browser Client Server Request:
DEV392: Extending SharePoint Products And Technologies Through Web Parts And ASP.NET Clint Covington, Program Manager Data And Developer Services - Office.
Anatomy of an ASP.NET Page. Slide 2 My Version of the Big Picture (1) ASP Worker (Engine) Your application Runs Server Other applications User 1User 2.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 1.1 of…
Web Platform Introduction With a focus on “free” Mike Taulty Developer & Platform Group Microsoft Ltd
IIS v7.0 Martin Parry Developer & Platform Group Microsoft Limited
IIS7: Building New Core Server Modules Michael Volodarsky COM406 Program Manager Microsoft Corporation.
Satisfy Your Technical Curiosity Internet Information Services (IIS) 7.0 End-to-End Overview of Microsoft's New Web Application Server Bart De Smet MVP,
ASP.NET 2.0 Chapter 6 Securing the ASP.NET Application.
Internet Information Server (IIS)
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
IIS 7: The Next Generation Web Application Server Platform Michael Volodarsky Program Manager Web Platform and Tools Team Microsoft Corporation.
Building Scalable and Reliable Web Applications Vineet Gupta Technology Evangelist Microsoft Corporation
April-June 2006 Windows Hosting Seminar Series Product Roadmap: IIS 7.0 Matthew Boettcher Web Platform Technical Evangelist (Hosting) Developer & Platform.
Enterprise Reporting with Reporting Services SQL Server 2005 Donald Farmer Group Program Manager Microsoft Corporation.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Saad Ladki Program Manager Microsoft Corporation WUX403.
Virtual techdays INDIA │ august 2010 IIS 7/7.5 Tips & Tricks Jaskirat Singh │ Technical Lead [IIS|Asp.Net team], Microsoft.
Delivering Excellence in Software Engineering ® EPAM Systems. All rights reserved. ASP.NET Authentication.
Microsoft ASP.NET: An Overview of Caching Holly Mazerolle Developer Support Engineer Microsoft Developer Support Microsoft Corporation.
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Programming the Web Using ASP.Net Chapter 2: The ASP.Net Template Dave.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
An Introduction to ASP.NET Ed Dunhill blogs.msdn.com/edunhill SLIDE7.
DEV402 Extending the ASP.NET Runtime Jurgen Postelmans Microsoft Regional Director BeLux U2U.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
Microsoft Internet Information Server (IIS) Judy Chen Mohammad Tiffany Le.
Internet Information Services (IIS) Oralia Resendez Pauline Cheng Xiao Yan Wu Stephen Tecci.
Efficient Deployment & Management of ASP.NET 2.0 Applications on IIS 6.0 Alexis Eller Program Manager Internet Information Services Microsoft Corporation.
The.NET Runtime and IIS Presented by Chris Dickey – cdickey.net consulting
ASP.NET State Management. Slide 2 Lecture Overview Client state management options Cookies Server state management options Application state Session state.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
Module 7: Creating a Microsoft ASP.NET Web Application.
Reset and Recycle IIS Reset Application Pool Management Error Codes New HTTP Sub-status codes Custom/Detailed Errors Tracing in IIS7 and.
Module 2: Overview of IIS 7.0 Application Server.
VITALE, CATURANO & COMPANY LTD Microsoft SharePoint Web Part Development Overview VITALE, CATURANO & COMPANY LTD SharePoint Developer Series – Web Part.
PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
IIS and.Net security -Vasudha Bhat. What is IIS? Why do we need IIS? Internet Information Services (IIS) is a Web server, its primary job is to accept.
Virtual techdays INDIA │ 9-11 February 2011 Caching Enhancement in ASP.NET 4.0 Abhijit Jana │ Consultant, Microsoft
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
Module 4: Design IIS Maintenance and UDDI. Designing Internet Information Services Backup and Recovery Specifying Monitoring requirements Deploying UDDI.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Migrating ASP to ASP.NET Matt Gibbs ASP.NET Development Manager.
Delivering Excellence in Software Engineering ® EPAM Systems. All rights reserved. Configuration.
IIS Manager Details Delegated Administration Configuration System.
Svetlin Nakov Telerik Corporation
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
For Developers Martin Parry Developer and Platform Group Microsoft
1 ASP.NET Internals
Internet Information Server 6.0 & new management features.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Alexey Polovinkin Post graduate student, CMC department.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
Developing Custom ASP.NET Providers For Membership And Role Manager Stefan Schackow PRS404 Program Manager – Web Platform and Tools Microsoft Corporation.
ASP.NET Architecture Mike Taulty Developer & Platform Group Microsoft Ltd
Building More Powerful ASP.NET Applications with IIS7 Michael Volodarsky COM303 Program Manager Microsoft Corporation.
ASP.NET Overview Brian Hitney Developer Evangelist Microsoft Corporation
ASP.NET 2.0 Mohammed Abdelhadi Developer.NET Evangelist Microsoft Corporation.
Arizona SharePoint Professionals Group.
ASP.NET Web Configuration File
ASP.NET Web Forms and Web Services
ASP.NET Application Framework
Application Infrastructure
Anatomy of an ASP.NET Page
ASP.NET Module Subtitle.
IIS v7.0 Martin Parry Developer & Platform Group Microsoft Limited
for Developers Martin Parry Developer and Platform Group Microsoft
ASP.NET 4.0 State Management Improvements – Deep Dive
IIS and .NET Security Application Pools Pamella Smith June 18, 2009.
Presentation transcript:

ASP.NET Architecture Internals Mike Shaw Developer & Platform Group Microsoft Ltd

Agenda Handling a request IIS5 and IIS6.0 Threads and ThreadPools Page processing Compilation Handlers and Modules PerformanceCaching Server GC Session State Configuration

IIS 5.0 Architecture INETINFO TCP/IP metabase ASP.NET ISAPI ASP.NET ISAPI Aspnet_wp.exe CLR App Domain DLLHOST.exe ISAPI Extensions (ASP, etc.) ISAPI Extensions (ASP, etc.) ISAPI Filters ASPNET account

WWW Service Config Mgr Process Mgr HTTP.sys Internet Information Server (IIS) 6.0 Architecture Web Garden W3WP.exe ISAPI Extensions (ASP, etc.) ISAPI Extensions (ASP, etc.) ISAPI Filters Application Pool 2 W3WP.exe ASP.NET ISAPI CLR Application Domain W3WP.exe ASP.NET ISAPI CLR Application Domain INETINFO metabase Application Pool 1 W3WP.exe ISAPI Extensions (ASP, etc.) ISAPI Extensions (ASP, etc.) ISAPI Filters Network Service Account

Robust Recycling and health detection Recycle worker process based on: UptimeSchedule # Hits Memory consumption On-demand Health detection Detecting worker process crashes Pinging = hang detection Kernel-mode queuing

IIS6 Process Recycling: Overlapping WWW Service Old Worker Process Web Process Core DLL ISAPI Ext and Filters New Worker Process Web Process Core DLL ISAPI Ext and Filters Ready for recycle Shut down HTTP.sys Request Startup Ready

IIS 6.0 application settings

HTTP.sys and Kernel-Mode Queuing HTTP.sys HTTP.sys API Listener HTTP Engine HTTP Parser Namespace Mapper Response Cache Req. Queue Send Response TCP/IP Request

ASP.NET Architecture / Threading IIS5 / ISAPI

ASP.NET Architecture / Threading Low Load

ASP.NET Architecture / Threading High Load

ASP.NET Architecture / Threading AspCompat

ASP.NET Request Processing Native Code.NET Code Application Host (IIS) ASP.NETPage ASP.NET Runtime ASP.NETServiceHTTPHandler HTTP Module Global.asax HttpContext Module Per Request Events: BeginRequestAuthenticateRequestAuthorizeRequestResolveRequestCacheAcquireRequestStatePreRequestHandlerExecute PostRequestHandlerExecuteReleaseRequestStateUpdateRequestCacheEndRequest

Agenda Handling a request IIS5 and IIS6.0 Threads and ThreadPools Page processing Compilation Handlers and Modules PerformanceCaching Server GC Session State Configuration

HTTP Pipeline

Web Forms Part Declarative, Part Code Combines declarative tags HTML, XML, WML, ASP directives, server controls and static text with code Clean separation between code and tags Form1.aspx code Form1.aspx code Form1.vb single fileseparate files Visual Studio.NET

How Does ASP.NET Work? Review ASP provided a linear execution model, executing script in the stream ASP.NET parses and generates a Page class with an event-based execution model Rendering the output stream is one phase of the Page execution

The parsed file is represented as a tree of controls The Page is the root of the tree Web form is declared by the runat=“server” attribute Ensures that the form is executed at the server </form> Static text (eg HTML without runat=“server” ) is represented as a “LiteralControl” in the hierarchy

3 Mandatory additions, 1 optional addition Names the class and/or language used Imports System.Web.Services Required namespace [WebMethod] or [WebMethod] or Method is ‘web callable’ WebService base class Access ASP.NET intrinsics.asmx Deconstructed

Runtime Compilation ASPX File Request ASPXEngine Parse Gen’d Page ClassGenerate Response Request Instantiate Response Code- behind class PageDLL Instantiate, Process and Render Compile

ASPNET_STATE INETINFO ASPNET_WP Caching HttpHandlers PagesServices ASP.NET Modular Architecture ASPNET_ISAPI AuthentSessions Session State HTTP Runtime HttpModules

ASP.NET Request Processing Pluggable, modular architecture URL Request Handlers (Http Handlers) Page Handler (.aspx) Web Service Handler (.asmx) Request Interceptors (Http Modules) CachingAuthentication/Authorization Session State

MethodPostBackControls ConstructorAlwaysAll AddParsedSubObjectAlwaysAll DeterminePostBackModeAlwaysPage OnInitAlwaysAll LoadPageStateFromPersistenceMediumPostBackPage LoadViewStatePostBackAll ProcessPostData1PostBackPage OnLoadAlwaysAll ProcessPostData2PostBackPage RaiseChangedEventsPostBackPage RaisePostBackEventPostBackPage OnPreRenderAlwaysAll SaveViewStateAlwaysAll SavePageStateToPersistenceMediumAlwaysPage RenderAlwaysAll OnUnloadAlwaysAll

HTTPHandlers Handle a request for a resource Implementation of IHttp(Async)Handler Can be an assembly or.ashx file.NET Code Application Host (IIS) ASP.NETPage ASP.NET Runtime ASP.NETServiceHTTPHandler HTTP Module Global.asax HttpContext

HTTPModules Used for request pre- and post- handler processing Implements IHttpModule Can be an assembly or in global.asax.NET Code Application Host (IIS) ASP.NETPage ASP.NET Runtime ASP.NETServiceHTTPHandler HTTP Module Global.asax HttpContext

ASPX Module events highlighted Application_Start Global_BeginRequest Global_AuthenticateRequest Global_AuthorizeRequest Global_ResolveRequestCache Global_Session_Start Global_AcquireRequestState Global_PreRequestHandlerExecute Page_DeterminePostBackMode Control_OnInit Control_TrackViewState Page_Init Page_TrackViewState Page_OnLoad Control_OnLoad Page_EnsureChildControls Page_CreateChildControls Page_OnPreRender Control_EnsureChildControls Control_CreateChildControls Control_OnPreRender Page_SaveViewState Control_SaveViewState Page_Render Page_RenderChildren Control_Render Control_RenderChildren Control_OnUnload Page_OnUnload Global_PostRequestHandlerExecute Global_ReleaseRequestState Global_UpdateRequestCache Global_EndRequest Global_PreSendRequestHeaders Global_PreSendRequestContent Application_End

Simple HTTPModule

Agenda Handling a request IIS5 and IIS6.0 Threads and ThreadPools Page processing Compilation Handlers and Modules PerformanceCaching Server GC Session State Configuration

Caching Support Full page output caching Vary by params, language, user-agent Fragment “Partial Page” Caching Enables portions of pages to be cached Extensible Cache API Developers can cache arbitrary objects eg results from database query Multiple expiration policies, file change invalidation

Output Caching Caches the static result of an ASP.NET page Declarative directive Optional Output Cache APIs can also be called Caching Options: Duration  Time item exists in the cache VaryByParam  Varies cache entries by Get/Post params  Name param, separate by semi-colons, supports * VaryByHeader  Varies cache entries by Http header VaryByCustom  Override method within Global.asax to custom vary by whatever you want (you control the cache key)

Partial Page Caching Caching the entire page isn’t always possible Partial page personalization, etc. Fragment Caching allows caching regions of a page by using user controls (.ascx) User controls define directive Additional Features VaryByControl – Varies cached items by controls VaryByCustom – Allows user cache key method

Cache API Caching output isn’t always possible Cache API allows objects to be cached In memory Hashtable System.Web.Caching.Cache class Page intrinsic property (Cache) Features: Dependencies (key, file, time) Unused items automatically expire Supports Callbacks ( CacheItemRemovedCallback ) /library/en-us/dnaspp/html/aspnet- cachingtechniquesbestpract.asp /library/en-us/dnaspp/html/aspnet- cachingtechniquesbestpract.asp

Fast And Scalable Kernel-mode caching ResponseCache Requestqueue Workerprocess HTTP.SYS Requestqueue ASP.NETWorkerprocess Kernel-mode cache No transition to user mode if in cache Static anonymous content

Kernel Caching in IIS6 ASP.NET leverages kernel cache on IIS6 As fast as static html in these cases Requirements for kernel cache promotion: HTTP GET Request (no posted pages) No VaryByParam No VaryByHeader No security restrictions to page Note: ASP.NET Request/Cache counters will not update when kernel hit occurs Monitor “Web Service Cache” counter group

Controlling the Cache

Sever GC heaps on MP machines mscorsvr.dll (not mscorwks.dll) has one heap with affinity per cpu CLR view: one heap Inter heap references possible GC Threads 0123 CPUs

Session State in-process, State Server, and SQL Server Session State can be external from ASP.NET process ASPState: Windows Service SQL Server ™ temp database (InstallPersistSqlState.sql) Big reliability wins Session state survives crashes/restarts Enables Web farm deployment Session State can be shared across a Web farm of ASP.NET Servers Applications no longer tied to one machine

Session State Run the State Server service: systemroot\Microsoft.NET\Framework\versionNumb er\aspnet_state.exe <sessionState mode="StateServer" <sessionState mode="StateServer" stateConnectionString="tcpip=dataserver:42424" stateConnectionString="tcpip=dataserver:42424" cookieless="false“ timeout="20"/> cookieless="false“ timeout="20"/> ASPNET_STATE INETINFO ASPNET_WP HttpHandlers PagesServices ASPNET_ISAPI Authent Sessions Session State HTTP Runtime

Session State Performance Remote session state incurs a performance hit over in-proc state Need to be more careful about usage Disable it pages that don’t use it by setting: Disable it pages that don’t use it by setting: Set “readonly” access if no updates are made to state: Set “readonly” access if no updates are made to state: Test Scenario: Store some simple scalar data within session intrinsic Three techniques measured: ASP.NET Session State InProc ASP.NET Session State State Server ASP.NET Session State SQL Server

Session State Performance

Agenda Handling a request IIS5 and IIS6.0 Threads and ThreadPools Page and service processing Compilation Handlers and Modules PerformanceCaching Server GC Session State Configuration

Configuration Stored in XML file in directory with pages web.config Contains all ASP.NET settings Authentication, compile options, custom error pages, etc. Allows adding Application settings DSN, etc. Extensible Can extend with custom application configuration data Hierarchical and starts with machine.config

#1 #1 SectionDescription Configures custom settings for an application. The settings in this section can be compared to application variables. Configures the authentication mode to determine which type of authentication to use. Configures authorization support and controls client access to URL resources. Configures the settings of the browser capabilities component. Configures all the compilation settings that ASP.NET uses. Provides information about custom error messages for an ASP.NET application. Configures the globalization settings for the application. Maps incoming URL requests to the IHttpHandler classes. Adds, removes, or clears HTTP modules within an application. Configures ASP.NET HTTP run-time settings.

#2 #2 SectionDescription Controls the application identity of the Web application. Configures keys to use for encryption and decryption of Forms authentication cookie data. This section allows you to configure a validation key that performs message authentication checks on view state data and forms authentication tickets. Identifies page-specific configuration settings. Configures the ASP.NET process model settings on IIS Web server systems. Note that you can only use this tag in the Machine.config file. Defines valid mappings of named security levels to policy files. Configures the session state module. Configures the ASP.NET trace service. Configures the set of code access security permissions that is used to run a particular application. Controls the settings of ASP.NET Web Services.

in machine.config in machine.config <processModel enable="true" timeout="Infinite" idleTimeout="Infinite" shutdownTimeout="0:00:05" requestLimit="Infinite" requestQueueLimit="5000" restartQueueLimit="10" memoryLimit="60" webGarden="false" cpuMask="0xffffffff" userName="machine" password="AutoGenerate" logLevel="Errors" clientConnectedCheck="0:00:05" comAuthenticationLevel="Connect" comImpersonationLevel="Impersonate" responseDeadlockInterval="00:03:00" maxWorkerThreads="20" maxIoThreads="20"/>

Misc Perf Config Gotchas Make sure debug is turned off Web.config : Web.config : VS.NET leaves in debug by default Make sure tracing is turned off Web.config and page directive IIS 6.0 Process Model Restarts Default restart is every 29 hours – turn off IIS 6.0 Maximum Used Memory Set to 60% of physical memory (keep < 800mb) Important to set if output cache used aggressively

Key Performance Counters Processor, CPU % Utilization Low numbers = blocking or lock contention ASP.NET, Requests Queued Linear growth here indicates server maxed ASP.NET Applications, Requests/Sec Dynamic throughput (should be consistent) ASP.NET Application, Errors Total Indicates functional problems (should be 0) ASP.NET App/Worker Process Restarts Indicates serious functional problems

Summary ASP.NET Architecture provides a flexible, extensible and configurable Dynamic Web Application Server ASP.NET runs best on Windows Server 2003 Scalability: Shared session, output Caching, Thread pooling, HTTP.SYS Reliability: Process recycling, managed code Secure: configurable trust, IIS Authentication Flexibility: Dynamic compilation and configuration

© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.