Continuation from my previous introductory post about AppFabric, it is very fundamental to know the architecture IIS 7.0 and WAS. Hence, this post.
In the above diagram, you can see two regions in Windows. The kernel mode and user mode, and you know that processes in the kernel mode touch the CPU and other hardware without any interface and have the rights to access physical memory without any virtual address mapping. The user mode processes are our own applications along with Windowing Subsystem which also includes Windows Network Subsystem. Processes in the user mode require processes in the kernel mode such as thread scheduling, memory, cache or IO related activities. So, it would require a thread context switching means that kernel model thread has been created and the data in the user mode thread has been transferred into kernel mode thread. Ahhh, I’m explaining too much about Windows processing. Let's cut off.
IIS 7 Components
Application Pool and Worker Process
Worker process is a Windows process which is specifically designed for hosting and running static, ASP or ASP.NET web applications in IIS. w3wp.exe is responsible for loading the appropriate ISAPI (a lower level programming module for handling specific web application, for example aspnet_isapi.dll for ASP.NET) filters and starts a new worker process for a request.
Application pool is a grouping of web applications which are routed to one or more worker processes. Processes in one application pool will not be impacted by another application pool’s failure.
Request Processing Pipeline and Modules
A request processing pipeline is created for every request. In the previous versions of IIS, if a request is for ASP.NET application, the application needs to exit from the IIS pipeline and load
aspnet_isapi for handling ASP.NET code which in turn creates its own request processing pipeline. In II7, both IIS and ASP.NET request pipelines are combined and called as “Integrated Pipeline“. This pipeline contains one or more modules. Module is a component which contains a specific set of features for IIS to handle a request. For example,
BasicAuthenticationModule is a module for performing basic authentication and
FileCacheModule is a module for caching files and file handles.
The integrated pipeline has the following benefits:
- Eliminating the duplication of features between IIS and ASP.NET, for example authentication
- One inventory for all IIS modules
WWW Service and WAS
It is necessary that a dedicated component is required for listening for requests and managing application pools and worker processes. In IIS 7, WAS (Windows Process Activation Service) is dedicated for this. Requests coming from different transports like HTTP, TCP/IP, NetPipe and MSMQ are handled by respective listener adapters configured in the WAS. When a request is coming which is directed to respective listener adapters which passes the request to appropriate worker process, where the application manager directs the request to the specific application.
WWW Service (World wide web publishing service, simply w3svc) is the listener adapter for HTTP. Apart from this, it manages the configuration stuff required for HTTP related.
Protocol Listeners and HTTP.sys (Kernel Mode)
As its name reflects, protocol listeners receive appropriate requests and pass them to the IIS. Note that protocol listeners are kernel mode processes. This model allows to handle any protocol, and the only thing we require is an appropriate device drive as HTTP.sys for HTTP requests.
Whenever an HTTP request is entering into the server, HTTP.sys receives the requests and passes it to the appropriate worker process if it exists, otherwise it puts the request in the request queue. When a response for a request is already in the response cache, it fetches that and replies back to it without noticing and invoking worker process.