Mark Friedman Architect Developer Division Microsoft Corporation
3
4
5
6
7
8
9
Network Latency Client-side script Server-side.aspx Network Latency Client-side script Server-side.aspx Network Latency Client-side script Server-side.aspx Unit TestLoad Test e.g., VS TeamTest Production 10
11
12
13
15
16
17
18
19
w3wp.exe Common Language Runtime (CLR) JIT compiler Garbage Collection threads mscoree.dll mscorsvr.dll MyApp.dll 20
Form: Code behind: Private Sub FileDropDownList_SelectedIndexChanged _ (ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles FileDropDownList.SelectedIndexChanged Session("FileSelected") = FileDropDownList.SelectedValue End Sub 21
22 IIS Architecture HTTP Request
23 See “IIS 7.0 Output Caching” at
24
25 From a command line: \windows\system32\inetsrv\appcmd list WP
27
28
Request Life-cycle Events Begin Request Authentication Authorization Resolve Cache Map Handler Acquire State Execute Handler Release State Update Cache Log Request Send Request 29
Event BeginRequest PreRequestHandlerExecute AuthenticateRequest PostRequestHandlerExecute PostAuthenticateRequest ReleaseRequestState AuthorizeRequest PostReleaseRequestState PostAuthorizeRequest PostMapRequestHandler ResolveRequestCache PostMapRequestHandler PostResolveRequestCache PostMapRequestHandler MapRequestHandlerUpdateRequestCache PostMapRequestHandlerPostUpdateRequestCache AcquireRequestState LogRequest PostAcquireRequestState EndRequest 30
31
Mark Friedman Architect Developer Division
33
34
35
36
37
38
39 See “How to Trace Requests for a Specific URL or Set of URLs” at dtechnol/WindowsServer2003/Library/II S/c56d19af-b3d1-4be9-8a6f- 4aa86bacac3f.mspx?mfr=true
40
41
EventUsage PreInit Create dynamic controls, set the Theme; master page, etc. Init Read or initialize control properties InitComplete Raised by the Page object. PreLoad Perform any processing on your page or control before the Load event. Load The Page calls the OnLoad event method on the Page, then recursively for each child control and its children Control events Button Clicks and other Control events are processed after Page_Load LoadComplete Fires after all controls on the page are loaded. PreRender Data binding for controls occurs now. SaveStateComplete Fires when the ViewState for all controls is complete and saved. Render Method that writes out the html markup associated with the control. Unload Do final cleanup, such as closing files or database connections 42
43
44
45
46
State Management ViewState Stored in _VIEWSTATE hidden field ControlState Override if ViewState is turned off on the Page HiddenField control Cookies Add cookie data to the Cookies collection in the HttpResponse object Query strings Application State HttpApplicationState Session State Profiles SqlProfileProvider 47
48
50
51
52
53 ASP.NET Session state HttpContext.Session Data associated with a logical sequence of Requests that need to be persisted across interactions Unique session IDs are passed along automatically with each Request as either cookies or embedded in the URL Session data is stored in a Dictionary collection, allowing individual session state variables to be accessed directly by Key name Three external storage options InProc StateServer SQL Server Timeout management
54 HttpContext.Session InProc option provides fastest service, but does not permit access to Session data from a different process in a Web garden application or a different Web server in a cluster Using alternatives to InProc session storage has significant performance implications StateServer SQL Server Custom provider Measure impact using the IIS RequestNotification events e.g., AcquireRequestState, PostAcquireRequestState
55 Session State options
56
57 Session State options
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 BindingResponse Time (msecs)Throughput wsHttpBinding basicHttpBinding netTcpBinding netNamedPipeBinding Source: Resnik, Crane, & Bowen, Essential Windows Communication Foundation, Addison Wesley, Chapter 4. See also, “A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies”A Performance Comparison of Windows Communication Foundation (WCF) with Existing Distributed Communication Technologies Caution: your mileage will vary. Caution: your mileage will vary.
Mark Friedman Architect Developer Division
92
93
94
95
96
97
98
99
100
Best Practices for Improving Page Load Time
102
103
104
105
106
107
108
109
110