IIS internal Running Mechanism

Source: Internet
Author: User
Tags metabase

ASP. NET is a very powerful platform for building Web applications. It provides great flexibility and capabilities that can be used to build all types of Web applications.

Most people are only familiar with high-level frameworks such as WebForms and WebServices-all of which are at the top of the ASP. NET hierarchy.

This document is collected from various documents published by Microsoft. By comparing the request processing processes of IIS 5, IIS 6, and IIS 7, we are familiar with ASP. NET underlying mechanism and how the request is transmitted from the Web server to ASP. NET runtime. By understanding the underlying mechanism, we can have a deeper understanding of ASP.net.

ASP.net request processing in IIS 5

Description of the graph:

A notable feature of IIS 5.x is the separation of Web Server and real ASP. NET Application. As a Web Server, IIS runs on a process named InetInfo.exe. InetInfo.exe is a Native Executive, not a hosted program, but our real ASP. NET Application runs on a Worker Process called aspnet_wp. It loads CLR during initialization, so it is a managed environment.

ISAPI: an application that can process various extensions. ISAPI is short for the following words: Internet Server Application Programe Interface, Internet Server Application Interface.

Features of IIS 5 mode:

1. First, only one aspnet_wp process can be run on the same host at the same time, and each ASP. NET Application corresponds to an Application Domain, that is to say, each Application runs in the same Worker Process. Application Isolation is based on Application Domain rather than Process.

2. Second, ASP. net isapi is not only responsible for creating the aspnet_wp Worker Process, but also responsible for monitoring the Process. If the Performance of aspnet_wp is detected to a lower limit, ASP. net isapi is responsible for killing the process. When aspnet_wp is terminated, subsequent requests will cause ASP. net isapi to re-create a new aspnet_wp Worker Process.

3. Finally, since IIS and Application are running in their respective processes, the communication between them must adopt a specific communication mechanism. Essentially, the communication between the InetInfo Process of IIS and the Worker Process is the communication between different processes of the same machine (local interprocess communications), which is considered for Performance, they use Named pipe-based communication mechanisms. Communication between ASP. net isapi and Worker Process is implemented through a set of Pipe between them. ASP. net isapi uploads the Request to the Worker Process asynchronously and obtains the Response. However, the Worker Process is synchronized to ASP. net isapi to obtain some Server-based variables.

 

IIS6 ASP.net request processing process

Description of the graph:

IIS 5.x listens to requests through InetInfo.exe and distributes requests to Work Process. In other words, in IIS 5. in User Mode, Request listening and distribution are performed. In IIS 6, this kind of work is transplanted to the kernel Mode. All of this is done through a new component: http. sys.

Note: To prevent users' applications from accessing or modifying critical operating system data, windows provides two processor access modes: User Mode and Kernel Mode ). Generally, the User program runs in User mode, while the operating system code runs in Kernel Mode. The Kernel Mode code allows access to all system memory and all CPU commands.

In User Mode, http. sys receives an http request based on aspx, And then it checks which Application Pool the Request-based Application belongs to based on Metabase in IIS. If the Application Pool does not exist, it is created. Otherwise, the request is directly sent to the Queue of the corresponding Application Pool.

Each Application Pool corresponds to a Worker Process: w3wp.exe, which is undoubtedly running in User Mode. The Application Pool and worker process Mapping are maintained in IIS Metabase. Based on such a ing, the WAS (Web Administrative service) transmits requests that exist in an Application Pool Queue to the corresponding worker process (if not, such a process is created ). When the worker process is initialized, ASP. net isapi and ASP. net isapi are loaded to load CLR. The final process is related to IIS 5. x is the same: Create an Application Domain for the Application through the Create method of AppManagerAppDomainFactory; process the Request through the ProcessRequest of ISAPIRuntime, and then enter the process to ASP. NET Http Runtime Pipeline.

 

ASP.net request processing in IIS 7

 

The IIS7 site starts and processes the request as follows:

Steps 1 to 6 are to process application startup. After the application is started, you do not need to perform this step again.

The eight steps are as follows:

1. When the client browser initiates an HTTP request for a WEB server resource, HTTP. sys intercepts the request.

2. HTTP. sys contacts WAS to obtain information from the configuration store.

3. WAS requests configuration information from the configuration storage center. ApplicationHost. config.

4. the WWW Service receives the configuration information, which is similar to the application pool configuration information and site configuration information.

5. Use the configuration information of the WWW Service to configure the HTTP. sys processing policy.

6. WAS starts a worker process for the application pool to which the request was made.

7. The worker process processes the request and returns a response to HTTP. sys.

8. The client receives the processing result information.

What if the W3WP.exe process is processed ?? The managed pipeline mode of the application pool of IIS 7 is divided into two types: Classic and integration. In these two modes, the processing policies are different.

 

 

Architecture of managed pipelines in IIS 6 and IIS7 in Classic Mode

Before IIS7, ASP. NET is added to IIS in the form of iis isapi extension. In fact, both ASP and PHP are configured in the same way. (PHP adopts two configuration methods in IIS, in addition to the iis isapi extension method and CGI method, the system administrator can select the PHP program execution method). Therefore, the client will first process the HTTP request to IIS through IIS, then, IIS handles HTML static Web Pages Based on the required content type. If not, it assigns them to their respective iis isapi extension based on the required content type; if the requested content type is ASP. NET.. net iis isapi extension, that is, aspnet_isapi.dll. This is the architecture.

The classic mode of the managed pipeline mode of the IIS 7 Application pool also works. This mode is compatible with IIS 6 to reduce the upgrade cost.

The execution architecture of IIS6 and the execution architecture of the IIS7 application pool configured in Classic Mode

 

Managed pipeline mode integration mode of IIS 7 Application pool

IIS 7 is fully integrated. NET, the processing order of the architecture is significantly different (for example), the main reason is ASP. NET from the IIS plug-in (ISAPI extension) role, enter the IIS core, and can also use ASP. the NET module is responsible for handling many types of IIS 7 Requirements. These ASP. the NET module cannot only process ASP. NET web applications, such as ASP, PHP, or static HTML web pages. NET has become a part of IIS 7, so ASP, PHP, or static HTML web pages can also use Forms Authentication) or Output Cache and other ASP.. NET 2.0 (but the setting value of IIS 7 must be modified ). Because IIS 7 allows you to use ASP.. net api development and add modules, so ASP. NET web developers will be more likely to expand the functions of IIS 7 and website applications, and even can independently. NET Program for managing IIS 7 (for example, program-controlled IIS 7 to build a website or virtual directory ).

Execution architecture diagram of IIS 7 (Architecture in managed channel mode)

 

Summary

IIS5 to IIS6 Improvements mainly include improvements to HTTP. sys.

The improvements from IIS6 to IIS7 mainly involve improvements to isapis.

References:

One of ASP. NET Process models: IIS and ASP. net isapi: http://www.bkjia.com/ OS /201110/108305.html

 

ASP. NET Internals-IIS and the Process Model

Http://dotnetslackers.com/articles/iis/ASPNETInternalsIISAndTheProcessModel.aspx

Modular IIS 7 and. NET capability Integration

Http://www.microsoft.com/taiwan/technet/columns/profwin/33-iis7-componentization-integration.mspx

Introduction to IIS 7.0 Architecture

Http://learn.iis.net/page.aspx/101/introduction-to-iis7-architecture/

 

From: ※small forest dwelling ※

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.