Basic concepts of IIS Web server/ASP. NET operating principles, iisasp.net

Source: Internet
Author: User

Basic concepts of IIS Web server/ASP. NET operating principles, iisasp.net
I started to record IIS-related notes from the company's test questions. What is the difference between Application Pool and AppDomain? I learned the knowledge of the process pool, so I recorded the study notes. We know now. NET employment, 80%. NET programmers are engaged in Web development. If they are not familiar with Microsoft's only (not unique now) Web server, it will be a bit embarrassing; (cannot be spoiled by Microsoft) the performance of a Web site does not depend on the Web server itself. IIS can be said to be a very powerful Web server. Now, Microsoft has made some basic knowledge about IIS 6.0 and IIS 8.5. In earlier days, Microsoft proposed the concept of a process pool on IIS, allowing multiple Web sites to run on one IIS access pool (w3wp.exe, how can we say there is good or bad? Fortunately, he saves the CPU and memory overhead, and the bad configuration in his process pool is not independent. The biggest problem is that a Web site crashes, all sites under the same process will be suspended. Even in Versions later than IIS 7, the site created by default will be an independent process pool. In fact, there is nothing mysterious to go deep into the Web server. The core is your design, how to properly handle requests, responses, and concurrency control; // Review: All Web servers are resolved at the network layer and HTTP protocol layer. 1. Earlier in IIS 6.0, the company was still using IIS 6.0. As an earlier version of Microsoft, various security problems continued, here, I am sorry for the remote code execution, data stream upload, and Identity Authentication Vulnerabilities of hard-pressed programmers .... resulting in many. NET developers think that it is not safe to store Web servers in Windows. In fact, the team behind Microsoft has worked very hard on patching and iteration. Note: 1. Do not Disable Windows Update on the server. 2. As a programmer, you have the responsibility to update Microsoft's dynamic and stable IIS versions. IIS 6.0 is not analyzed too much because it is too old. 2. IIS running process (this is easy to understand and pretend to be writing a Web server) First, the principles and details of HTTP request specifications are not explained. We all know that the IIS Web server listens to port 80 by default, so the listening process must be supported, HTTP. the sys component is responsible for listening to all HTTP requests. After listening to the request, the scheduler request information (w3wp.exe/Application Pool) is allocated to the corresponding Pool. The process Pool responds after processing the request; // as mentioned above, all the sites must depend on the IIS process pool. After the process pool is started, an independent W3WP.exe process 1 and HTTP. SYS :( Kernel) is a component that listens (Listen) HTTP requests from external sources and forwards the requests to the corresponding Application Pool based on the request URL ). When the HTTP request is processed, it is also responsible for sending the processing results. To provide better performance, HTTP. sys internally creates a buffer to save the processing results of recent HTTP requests. 2. Application Pool: IIS always maintains a separate working process: Application Pool. All processing occurs in this process, including ISAPI dl l execution. The application pool allows you to control the execution of a specified process at a lower granularity. You can configure an application pool for each virtual directory or the entire Web site, which makes it easy for you to isolate each application into its own process, in this way, it can be completely isolated from other programs running on the same machine. From the perspective of Web processing, if a process dies, at least it will not affect other processes. When the application pool receives an HTTP request, it is handed over to the Worker Process: w3wp.exe running in the application pool to Process the HTTP request. 3. Worker Process: After a Worker Process receives a request, it first finds and loads the corresponding ISAPI extension based on the suffix (for example, the aspx ing is aspnet_isapi.dll ), after the job process loads aspnet_isapi.dl l, aspnet_isapi.dll loads ASP.. NET application running environment is CLR (. NET Runtime ). Worker Proces s runs in an unmanaged environment, while objects in. NET run in a hosted environment (CLR). The bridge between them is ISAPI extension. 4. WAS (Web Admin Service): This is a monitoring program. It can access various information stored in the InetInfo Metabase, and monitor the Application Pool) when necessary, it will shut down an old worker process and create a new replacement. Figure: what is the role and lifecycle of the ISAPI of the classic pipeline in the process pool? How can I understand the begging and disposal pipelines in an integrated pipeline? Ii. ASP. NET running principle (analysis) See figure: (AppDomain running process diagram) AppDomain role, I believe everyone understands it. here are a few simple points: 1. Objects Created by code in one AppDomain cannot be directly accessed by code in another AppDomain (they can only be sent by reference or by value, 2. AppDomain can be detached. CLR does not support the ability to detach an assembly from AppDomain, but it can tell CLR to detach an AppDomain, this allows you to uninstall all the Assemblies currently included in the AppDomain. 3. AppDomain can independently protect the important data structures used by the host itself after the host loads some code .. 4. The AppDomain configuration can affect the way in which CLR loads an assembly in the AppDomain, including search path, version binding redirection, shadow copying, and loader optimization. From the above points, we can see that AppDomain ensures the robustness of the Windows system and the applications running in it. AppDomain provides the isolation required to protect, configure, and terminate each of these applications. Let's take a look at the ProcessRequest Process: A Brief Analysis of ProcessRequest (HttpWorkerRequest wr) to determine whether wr is null, and then to determine whether the pipeline is complete, and then call the ProcessRequestNoDemand (wr) method, determine whether the current RequestQueue is null, then calculate the wait time and update the number of pipelines CalculateWaitTimeAndUpdatePerfCounter (wr); reset the wr start time wr. resetStartTime (); call the ProcessRequestNow (wr) method and call the ProcessRequestInternal (wr) method;

Here, we must be able to make a simple review of the ASP. NET Pipeline mechanism. Of course, there are still a lot of places without detailed analysis. Next, we will summarize the IIS running process and ASP. NET Pipeline mechanism: Request → (Internet) HTTP. sys listener → WAS (IIS6 web Admin Service/IIS7 (Windows Activation Service) receives requests → (incoming) Application Pool's → w3wp.exe (check URL suffix) → (load) ISAPI extension [aspnet_isapi.dll] → register the htting to construct the HttpRuntime class → generate the ProcessRequest method HttpContext instance (Request, Response, Session and so on ...) HttpRuntime calls HttpApplicationFactory to load the HttpApplication object to reach HttpHandler through the HttpModule. It simply uses 140 characters (that is, the number of words in a microblog): Request → (Internet) HTTP. sys → (WAS) → Application Pool's → w3wp.exe → ISAPI → Map → (Pipeline) HttpWorkerRequest → AppDomain → HttpRuntime → ProcessRequest () → HttpContext (Request, Response) → HttpRuntime → HttpApplicationFactory → HttpApplication → HttpModule → HttpHandler → EndRequest

Related Article

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.