Title: IIS 6.0 (1) , PMP/MCSE yy@yuyong.net
1IIS6.0?????????IIS 6.0??? (1)
? ?, PMP/MCSE ?????? yy_at_yuyong.net ????www.yuyong
.net
2????
- IIS 6.0?????
- Windows????
- IIS 6.0????
- HTTP.SYS
- IIS 6.0 New Isolation Mode
- WAS, Worker Processes and App Pools
- IIS 6.0?Reliability?Scalability?????
3IIS 6.0?????
- 99.999 Availability
- 5 9s availability through better isolation of
code - Increased Reliability
- Reliability through health monitoring and process
recycling - Improved Performance
- Performance improvements through kernel mode
driver and response cache - Enhanced Management
- Robust and Accessible configuration store via XML
Metabase and WMI provider
4Windows????
5Windows????
6IIS 6.0???
7IIS 6.0??????
- HTTP.SYS
- IIS 6.0 New Isolation Mode
- WAS, Worker Processes and App Pools
8HTTP.SYS
- What is it?
- Universal HTTP processor for Windows
- Always running
- Availability
- Isolation of Listener function
- Request queue management
- Performance Features
- Kernel-mode response cache
- One-time parsing of HTTP request
9The Internals of HTTP.SYS
10HTTP.SYS Functions
- The main role of HTTP.SYS is to listen for HTTP
requests through TCPIP.SYS and return responses
to the client however, it has other duties, such
as - Managing TCP connections.
- Validating HTTP requests
- Routing HTTP requests to the correct application
pool. - Caching of responses in kernel mode.
- Performing all text-based and centralized binary
logging for the Web service (not ODBC). - Implementing features such as connection limits,
connection time-outs, queue-length limits, and
bandwidth throttling for IIS.
11Https Cache Flow
12IIS 6.0 New Isolation Mode
- ?????????
- IIS 5.0????
- IIS 6.0???????????
- Worker process isolation mode
- IISĀ 5.0 isolation mode
13IIS 5.0????
14IISĀ 5.0 isolation mode
15Worker process isolation mode
16Worker Processes and App Pools
- Application Pool work-horse
- Handles requests routed to app pool
- Mini-web servers
- Contains all W3SVC functionality
- Loads ISAPIs both site filters and extensions
- Separates W3SVC from INETINFO
17W3ADMs Management Role
- W3ADM is responsible for controlling the lifetime
of the worker processes - When to start a worker process
- When to recycle a worker process if it is unable
to process any more requests (becomes blocked). - CPU monitoring is configured to stop an app pool
after consuming too much CPU. - Initiation of rapid-fail protection causes an
application pool to stop. - A configuration error caused by trying to use an
incorrect identity causes an application pool to
stop. - A Windows administrator performs a demand stop or
start on an application pool. - In IIS5IM mode, W3ADM will try attempt to restart
INETINFO if it crashes.
18Worker Process
- Contains a master DLL (W3CORE.DLL) that
implements all request handling logic - Requests are routed through HTTP.SYS to the
worker process and W3SVC - Is effectively administered and managed by W3SVC
- Can be loaded into INETINFO (IIS5IM) or W3WP.exe
(WPIM) - Serves only one app pool
19Application Pools
- A group of one or more URL namespaces served by a
worker process - Can be started and stopped like sites
- Can be configured for health detection,
recycling, etc. - Serve all content for a web app (vs. only ISAPI
on IIS4/5)
20HTTP.SYS and Application Pools
- HTTP.SYS requests a worker process for the app
pool if there is demand. - If the app pool is not started, requests for the
app pool will receive a Service Unavailable
message. - If a worker process has been shut down by W3ADM,
then HTTP.SYS can restart it if the
AppPoolAutoStart metabase property is set to TRUE
(the default).
21Web Gardens
- An app pool served by more than one worker
process is a web - garden.
- To enable this, set the MaxProcess value gt 1.
- A benefit to Web gardens is that if one worker
process gets bogged down (script engine hangs),
there are other worker processes available to
accept and process requests.
22Processor Affinity
- Setting processor affinity means assigning
specific processes or applications to a specific
processor. - Controlling processor affinity can improve
performance by reducing the number of processor
cache flushes as threads move from one processor
to another. - Advanced configurations using Web gardens and
processor affinity can be used on multi-processor
computers where clusters of CPUs can be dedicated
to specific application pools.
23Brief Overview .NET Application Domains vs.
Application Pools
- Application Domains
- Lightweight CLR unit of isolation
- One application domain per IIS application
- Combine with W3WP.exes to achieve high
scalability and isolation - ASP.NET manages application domains independently
- Recycled within a single process
- Can have private components, session variables ,
etc.
24Reliability Best PracticesIsolating Apps in
Application Pools
- Can create one or more application pools
- Each served by one or more W3WP.exes.
- Each W3WP.exe serves only one pool.
- Reqs routed directly to pool by HTTP.sys
- Isolate applications based on
- Site/Customer
- Functionality
- Reliability
- Application version (as long as each has separate
URL) - Best Practices
- Timeout Pool put misbehaving applications in a
more restrictive pool - Leaks ? throttle back memory usage
- Crashes ? enable Rapid Fail Protection.
- Isolate critical applications in their own pool
- MS.COM best practice separate ASP and ASP.net
applications
25Reliability Best PracticesPinging Auto Health
Detection
- Pinging
- Periodic check to ensure at least 1 thread is
available to do work - Can set Frequency of Ping, response time per pool
- Orphaning -gt if ping fails, can take action
- REPORT_UNHEALTHY
- ISAPI SSF
- Used with Ping to request a recycle if
unhealthy - ASPNET used in conjunction w/ResponseDeadlockInter
val - Best Practices
- Use Pinging to ensure IIS w3wp and ASPNET have
threads available to do work - Check NT App Log for Warnings from W3SVC-WP
Event Type Warning Event Source W3SVC-WP Event
Category None Event ID 2262 Date 5/4/2003 Tim
e 10233 PM Computer ltCOMPUTERNAMEgt Descrip
tion ISAPI 'C\aspnet_isapi.dll' reported
itself as unhealthy for the following reason
'Deadlock detected'.
26Reliability Best PracticesPeriodic Process
Recycling
- What is it?
- Periodically restart applications based on
- Default Uptime
- of requests
- Scheduled time
- Memory consumption (virtual memory and actual
used memory) - On-demand
- Why use it?
- Refresh apps to ensure availability
- Prevent bad apps from taking over the system
- Session/App State
- In-proc state is lost when process is terminated
- Use OOP Session State management (ASPNET_STATE,
SQL) to persist state!
27Reliability Best PracticesOverlapping Recycle
Ready for Recycle
user
kernel
28Reliability Best PracticesOverlapping Recycle
Ready for Recycle
user
kernel
29Reliability Best PracticesOverlapping Recycle
ready
user
kernel
30Reliability Best PracticesOverlapping Recycle
Shut down
user
kernel
31Reliability Best PracticesOverlapping Recycle
user
kernel
32RecyclingOverlapping vs. Non-Overlapping
- Overlapping Recycle
- Terminates only old process after new process
starts - Possible for apps to be instantiated multiple
times
- Non-Overlapping Recycle
- Terminates old process first
- Then starts new process to replace it
- Reduces multi-instance problems
BOTH still queue requests in the kernel No
interruption in service!
33Reliability Best PracticesRecycling Best
Practices
- Overlapping Recommendations
- Use Overlapping (default) wherever possible
- If unable to use Overlapping
- Increase AppPools AppPoolQueueLimit if youre
getting 503s (QueueFull error in HTTPERR log) - CAUTION doing so will consume more memory when
queuing. - Recycling Recommendations
- Disable (default) Uptime-based recycling for .NET
App-hosting Pools - Monitor w3wp.exe private bytes, look for plateau.
- gt 800mb Increases risk of .net OutOfMemory
Exceptions - Use iisapp.vbs to map PID to pool
- Use PeriodicRestartPrivateMemory to control
memory usage - Max PeriodicRestartPrivateMemory value for pools
hosting .NET apps should be MIN(800mb, 60
physical ram)
34Scalability Best PracticesHTTP.SYS Kernel Caching
HTTP.SYS API
HTTP.SYS
Send Response
Listener
Req. Queue
Req. Queue
Req. Queue
Namespace Mapper
Response Cache
HTTP Engine
HTTP Parser
TCP/IP
35Scalability Best PracticesHTTP.SYS Kernel Caching
HTTP.SYS API
HTTP.SYS
Send Response
Listener
Req. Queue
Req. Queue
Req. Queue
Namespace Mapper
Response Cache
HTTP Engine
HTTP Parser
TCP/IP
36Scalability Best PracticesHTTP.SYS Kernel Caching
HTTP.SYS API
HTTP.SYS
Send Response
Listener
Req. Queue
Req. Queue
Req. Queue
Namespace Mapper
Response Cache
HTTP Engine
HTTP Parser
TCP/IP
37Scalability Best PracticesHTTP.SYS Kernel Caching
HTTP.SYS API
HTTP.SYS
Send Response
Listener
Req. Queue
Req. Queue
Req. Queue
Namespace Mapper
Response Cache
HTTP Engine
HTTP Parser
TCP/IP
38Scalability Best PracticesHTTP.SYS Kernel Cache,
part 2
- Benefits
- Much faster to serve response no transition to
user mode - 15k req/s from Kernel Cache vs. 1.3k req/s from
ASPNET output cache - Lighter load on CPU (though more kernel CPU time)
- Using it in ASP.net
- Complete responses can be cached by
- REMEMBER your application wont see subsequent
requests for this URL after caching once. - Standard cache flush semantics apply
- If on UNC, be sure to have MaxCmds set high
enough - Otherwise ? failed to start monitoring changes
to directory \\svr\share\webcontent
lt_at_ OutputCache LocationServer gt
39Scalability Best PracticesHTTP.SYS Kernel Cache,
part 2
- Things that would prevent a response from being
cached by HTTP.sys - Requests requiring Authentication (AUTHENTICATE)
- Filters installed that are not cache-aware
(FilterEnableCache FALSE default) - Process gets recycled all cache entries for
that process are flushed - Content changes
40Scalability Best PracticesIdle Timeout and
Demand Start
- Idle Timeout
- Time out and shut down idle processes if process
is idle for given period of time - Frees resources for active applications
- Apps still available even if worker process idles
out and is shut down! - Demand Start
- Start worker process only if theres demand for
the App Pool - DemandStartThreshold only start/run a max of x
w3wp.exe processes on the server at any time - Best Practices
- Use Idle Timeout to free up resources for other
heavy-use applications - W3wp.exe uses 20mb private bytes w/ASPNET loaded
(no applications) - w/HelloWorld (30 concurrent conns) you go up to
30mb - Consider disabling idle timeout if app startup
takes a long time - More Pools ? consider using more aggressive
IdleTimeout to recover memory quicker
41Scalability Best PracticesIIS 6 Web Gardens and
Processor Affinity
- Web Gardens
- App Pool w/ gt 1 worker process
- Connection-based routing w/in Garden
- Not processor based (can enable on 1 CPU
server) - Processor Affinitization
- Bind app pool process/es to 1 or more CPUs
- Mask-based configuration
Web Garden application pool
W3SVC
HTTP.SYS
42Scalability Best PracticesWeb Gardens and
Processor Affinity BPs
- Web Garden Best Practices
- Not beneficial in most cases only good for
following specialized applications - Application is multi-instanceable
- Application is not CPU-intensive
- Application has synchronous high latency backend
(or sync high latency anywhere) - Affinity Best Practices
- Affinitize pool to a POD (or hemisphere)
- In general, 4CPU is optimal case for affinity
- Try affinitizing NICs to CPUs too (distribute NIC
interrupts) - Done using SMPAffinitized True using
SMPProcessorAffinityMask
43Scalability Best PracticesWeb Gardens and
Processor Affinity BPs
- Web Garden Best Practices
- Not beneficial in most cases only good for
following specialized apps - Application is multi-instanceable
- Application is non-CPU intensive
- Application has synchronous high latency backend
(or sync high latency anywhere) - Affinity Best Practices
- Affinitize pool to a POD (or hemisphere)
- In general, 4CPU is optimal case for affinity
- Try affinitizing NICs to CPUs too (distribute NIC
interrupts) - Done using SMPAffinitized True using
SMPProcessorAffinityMask
ltIIsApplicationPool Location "/LM/W3SVC/AppPool
s/BuildingBlock0" //Procs 0-3 SMPAffinitized"TR
UE" SMPProcessorAffinityMask28"15" gt
ltIIsApplicationPool Location
"/LM/W3SVC/AppPools/BuildingBlock1" //Procs 4-7
SMPAffinitized"TRUE" SMPProcessorAffinityMask
"240" gt
44Scalability Best PracticesControlling Resource
Usage
- Use IIS Memory Recycling (private bytes
PeriodicRestartPrivateMemory) - Watch for w3wp.exe private bytes exceeding 800mb
- ASPNET OutOfMemory Exceptions attributed to
address space fragmentation - Reduce PeriodicRestartPrivateMemory to recycle
sooner to prevent this from occurring (start at
just under 800mb) - CPU Throttling
- Use Windows System Resource Manager (Windows
Server 2003 Ent and Data Center only) to control
CPU usage - Put mission critical applications in their own
pools, and create WSRM policies for those pools
to ensure they get CPU when they need it
45????
- MSDN Webcast IIS Architecture Overview
- IIS 6.0 ???
- TechNet Webcast Have Your Cake and Eat It, Too
Understanding How ASP.NET Works with IIS 6.0 - TechNet Webcast The Ins and Outs of Web Service
Extensions in IIS 6.0 - TechNet Webcast HTTP.sys Inside and Out
- IIS6 Reskit Book (downloadable book)
- CHAPTER_2_IIS_6.0_Architecture.doc
46TechNet????
- ??????,????????
- ??IT ??????,TechNet ????????,???????????,?????????
??????
- ??????????? DVD??CD
- ????????,??????????????????
??TechNet
- ??????? www.microsoft.com/china/technet
- ???????
- ??--????????
TechNet ??
- ?????????????
- ????, ??????
TechNet ??????
- ????????????????
- ????, ???????
TechNet ?? ?????
????
47?????????? TechNet?
- ??TechNet?????www.microsoft.com/China/technet
- ??TechNet?? www.microsoft.com/china/technet/aboutt
n/subscriptions/flash.mspx - ????????? http//www.microsoft.com/china/communit
y/ - ?? TechNet???
- www.microsoft.com/china/technet
- ??????TechNet?????????www.microsoft.com/china/tec
hnet
48????,?????!