Upload
cory-tyler
View
216
Download
2
Tags:
Embed Size (px)
Citation preview
Building Scalable and Building Scalable and Reliable Web ApplicationsReliable Web Applications
Vineet GuptaVineet GuptaTechnology EvangelistTechnology EvangelistMicrosoft CorporationMicrosoft Corporation
http://spaces.msn.com/members/vineetguptahttp://spaces.msn.com/members/vineetgupta
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
DLLHost.EXE
ISAPIExtensions
DLLHost.EXE
ISAPIExtensions
Rearchitecting IISRearchitecting IISA review of IIS5A review of IIS5
TCP/IPkernel
user WinSock 2.0
INETINFO.EXE
Metabase
ISAPI Filters and Extensions DLLHost.EX
E
ISAPIExtensions
INETINFO.EXE
MetabaseMetabase
ISAPI Filters and Extensions
web web appapp
IIS 6.0 ArchitectureIIS 6.0 Architecture
Goal: Enable complete app Goal: Enable complete app isolation from other Web isolation from other Web apps and core Web serverapps and core Web server
Web service in INETINFO Web service in INETINFO split out to do this:split out to do this:
Http.sys: Kernel mode Http.sys: Kernel mode listener and request routerlistener and request router
WAS: Config and process WAS: Config and process managermanager
W3wp.exe: Where Web apps W3wp.exe: Where Web apps are processedare processed
Multiple W3wp.exe filesMultiple W3wp.exe files
WASWASW3wp.exeW3wp.exe
web web appapp
Http.sysHttp.sys
Ker
nel
Ker
nel
W3wp.exeW3wp.exe
web web appapp
W3wp.exeW3wp.exe
Web Web AppApp
Process Model ContrastProcess Model Contrast IIS5 to IIS6 – Making it more robustIIS5 to IIS6 – Making it more robust
HTTP.SYSHTTP.SYSHTTP.SYSHTTP.SYS TCP/IP TCP/IP ConnectionsConnections
RequestsRequests
User Mode
Kernel Mode
App2App2
FiltersFilters
Worker Worker ProcessProcess
App2App2
FiltersFilters
Worker Worker ProcessProcess
App1App1
FiltersFilters
Worker Worker ProcessProcess
WASWASWASWAS
INETINFOINETINFO
metabasemetabase
AppPool 1AppPool 1 AppPool 2AppPool 2
ASP.Net on IIS 6ASP.Net on IIS 6.NET Application Domains vs. Application Pools.NET Application Domains vs. Application Pools
Application domainsApplication domainsLightweight CLR unit of isolationLightweight CLR unit of isolation
One app domain per IIS applicationOne app domain per IIS application
Combine with W3wp.exe files to Combine with W3wp.exe files to achieve high scalability and isolationachieve high scalability and isolation
ASP.NET manages app domains ASP.NET manages app domains independentlyindependently
Recycled within a single processRecycled within a single process
Can have private components, Can have private components, session variables , etc.session variables , etc.
Http.sysHttp.sys
W3wp.exeW3wp.exe
ASP.NETASP.NETWASWAS
App poolApp pool
W3wp.exeW3wp.exe
ASP.NETASP.NET
AppApp
DomainDomainAppApp
DomainDomainAppApp
DomainDomainAppApp
DomainDomainAppApp
DomainDomainAppApp
DomainDomainAppApp
DomainDomainAppApp
DomainDomain
Application PoolApplication Pool
W3wp.exeW3wp.exe
ASP.NETASP.NET
App poolApp pool
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
Application PoolsApplication PoolsApplication Isolation in ProcessesApplication Isolation in Processes
Can create 1 or more Can create 1 or more application poolsapplication pools
Each served by 1 or Each served by 1 or more processes.more processes.
Each worker process Each worker process serves only 1 pool.serves only 1 pool.
Reqs routed directly to Reqs routed directly to pool by HTTP.syspool by HTTP.sys
Isolate apps based Isolate apps based on:on:
Site/CustomerSite/Customer
FunctionalityFunctionality
ReliabilityReliability
RecyclingRecyclingWhat is it and Why use it?What is it and Why use it?
What is it?What is it?Periodically restart Periodically restart applications based on:applications based on:
UptimeUptime# of requests# of requestsScheduled timeScheduled timeMemory consumptionMemory consumptionOn-demandOn-demand
Why use it?Why use it?Refresh apps to ensure Refresh apps to ensure availabilityavailabilityPrevent bad apps from Prevent bad apps from taking over the systemtaking over the system
No interruption in No interruption in Service!!Service!!
RecyclingRecyclingOverlapping RecycleOverlapping Recycle
kernel
user
WA
SW
AS
HTTP.SYSHTTP.SYS
Old Old Worker Worker ProcessProcess
ISAPI Exts &ISAPI Exts &FiltersFilters
Web Proc. Web Proc. Core DLLCore DLL
Ready for Ready for
RecycleRecycle
New New Worker Worker ProcessProcess
ISAPI Exts &ISAPI Exts &FiltersFilters
Web Proc. Web Proc. Core DLLCore DLL
Shut downShut down
RequestRequest
startupstartupreadyready
RequestRequest
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
Increasing .NET Scale & PerformanceIncreasing .NET Scale & PerformanceAttributes of Scalable Web ApplicationsAttributes of Scalable Web Applications
StatelessStatelessApplication code and components can be Application code and components can be restarted cheaply; session state is restarted cheaply; session state is managed externally in some sort of state managed externally in some sort of state storestore
Low initialization costsLow initialization costsApplications should avoid doing heavy Applications should avoid doing heavy processing at startup or assume that they processing at startup or assume that they will run for a long timewill run for a long time
Increasing .NET Scale & PerformanceIncreasing .NET Scale & PerformanceAttributes of Scalable Web ApplicationsAttributes of Scalable Web Applications (2) (2)
Can have multiple instancesCan have multiple instancesAll the components and classes of an All the components and classes of an application should be able to have multiple application should be able to have multiple instances in separate processes without instances in separate processes without namespace or locking issuesnamespace or locking issues
Expect administrator-imposed limitsExpect administrator-imposed limitsYour application is likely to haveYour application is likely to have
CPU limitsCPU limitsMemory limitsMemory limitsProcessor affinity imposedProcessor affinity imposed
Making Applications More ReliableMaking Applications More Reliable
Web Farm Session StateWeb Farm Session State
Session state can be stored in an external Session state can be stored in an external processprocess
ASPState Service ASPState Service MicrosoftMicrosoft®® SQL Server SQL Server™™ 2000 2000
Big reliability wins Big reliability wins Session state survives crashes/restartsSession state survives crashes/restarts
Enables Web farm deploymentEnables Web farm deploymentSession state can now be shared across a Web Session state can now be shared across a Web farm of ASP.NET serversfarm of ASP.NET serversApplications no longer tied to one computerApplications no longer tied to one computer
Design your apps to be recycled!Design your apps to be recycled!
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
Dynamic Kernel CachingDynamic Kernel Caching
Cache
Network Stack
HTTP.SYS
W3WP.EXE (IIS6.0)
ASP.NET/CLR
User Application
UserKernel
Database
RequestRequest ResponseResponse
WithoutWithoutCacheCache
Cache
Network Stack
HTTP.SYS
W3WP.EXE (IIS6.0)
ASP.NET/CLR
User Application
UserKernel
Database
WithWithCacheCache
RequestRequest ResponseResponse
ASP.Net 2.0 Caching ImprovementsASP.Net 2.0 Caching ImprovementsData CachingData Caching
Data-set based data-sources can be Data-set based data-sources can be easily cachedeasily cached
Just set EnableCaching to true on data-Just set EnableCaching to true on data-source controlsource control
Also set CacheDuration, CacheExpirationPolicyAlso set CacheDuration, CacheExpirationPolicy
SQL Cache Invalidation for Stale DataSQL Cache Invalidation for Stale DataSQL 7, 2000 use a custom change table, a SQL 7, 2000 use a custom change table, a DB trigger and a polling mechanism by DB trigger and a polling mechanism by ASP.NetASP.Net
SQL 2005 uses Service BrokerSQL 2005 uses Service Broker
ASP.Net 2.0 Caching ImprovementsASP.Net 2.0 Caching ImprovementsPost-Cache Substituion Post-Cache Substituion
Output Cache an entire page except XXXOutput Cache an entire page except XXXXXX must be a simple stringXXX must be a simple string
Use Response.WriteSubstitution with Use Response.WriteSubstitution with callbackcallback
Or Use Substitution Control with Or Use Substitution Control with associated Callback methodassociated Callback method
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
Resource Optimization in IIS 6Resource Optimization in IIS 6Idle Timeout and Demand StartIdle Timeout and Demand Start
Idle timeoutIdle timeoutTimeout and shutdown idle processes if process Timeout and shutdown idle processes if process is idle for given period of time.is idle for given period of time.Frees resources for active applications.Frees resources for active applications.Apps still available even if worker process idles Apps still available even if worker process idles out and is shut down! out and is shut down!
Demand startDemand startOnly start worker process if there is demand for Only start worker process if there is demand for the application pool. the application pool.
Application considerationsApplication considerationsUse idle timeout to free up resources for other Use idle timeout to free up resources for other heavy-use applications.heavy-use applications.Consider disabling idle timeout if starting an Consider disabling idle timeout if starting an application takes a long time.application takes a long time.
View State ImprovementsView State Improvements
More efficient More efficient serialization format serialization format reduces state sizereduces state size
Splitting View State Splitting View State into Control State into Control State and UI Stateand UI State
Site CompilationSite Compilation
Pre-Compile your websitePre-Compile your websiteUse aspnet_compiler.exeUse aspnet_compiler.exe
Endpoints reduced to empty files Endpoints reduced to empty files (aspx)(aspx)
No request-time compilationNo request-time compilation/bin contains compiled assemblies for /bin contains compiled assemblies for entire siteentire site
AgendaAgenda
IIS 6.0 and ASP.Net ArchitectureIIS 6.0 and ASP.Net Architecture
ReliabilityReliability
State ManagementState Management
CachingCaching
Other Cool StuffOther Cool Stuff
RecommendationsRecommendations
Move to IIS 6 and ASP.Net 2.0Move to IIS 6 and ASP.Net 2.0
Design Apps for RecyclingDesign Apps for Recycling
Design Stateless AppsDesign Stateless AppsOr think out-of-proc state managementOr think out-of-proc state management
Use Caching wherever you can!Use Caching wherever you can!
Questions?Questions?
http://spaces.msn.com/members/vineetguptahttp://spaces.msn.com/members/vineetgupta
Your FeedbackYour Feedbackis Important!is Important!
Please Fill Out the Please Fill Out the feedback formfeedback form