ASP. NET Web Garden Model

Source: Internet
Author: User

Web Garden Model

The Web Garden model can be configured through the <processModel> section in the machine. config file. Note that the <processModel> section is the configuration section that cannot be placed in the application-specific web. config file. This means that the Web Garden mode can be applied to all applications running on the computer. However, by using the <location> node in the machine. config source file, you can adjust the computer settings for each application.

The <processModel> section has two attributes that affect the Web Garden model: Web Garden and cpuMask. The Web Garden property accepts a Boolean value, indicating whether multiple auxiliary processes are used. One CPU corresponds to one process ). By default, the value of this attribute is false. The cpuMask attribute stores a DWORD value. The binary representation of this value provides bitwise shielding for CPUs that can run ASP. NET auxiliary processes. The default value is-1 (0 xFFFFFF), indicating that all available CPUs can be used. If the Web Garden attribute is false, the content of the cpuMask attribute is ignored. The cpuMask attribute also sets an upper limit for the number of running copies of aspnet_wp.exe.

It is often said that "Not all the flash is gold", which is suitable for use here. The Web Garden mode allows multiple secondary processes to run simultaneously. However, you must note that all processes have their own application status, in-process session Status, ASP. NET cache, static data, and other content required to run the application. After the Web Garden mode is enabled, ASP. net isapi will start as many auxiliary processes as possible based on the number of CPUs, each of which is the complete clone of the next process, and each process is closely related to the corresponding CPU ). To balance the workload, incoming requests are divided between running processes in a single loop. Auxiliary processes are recycled just as they are in a single processor. Note that ASP. NET inherits all the CPU usage restrictions of the operating system and does not include the custom semantics of the restrictions.

In short, the Web Garden model does not apply to all applications. The more States an application has, the more performance loss it has. The work data is stored in the shared memory block so that the input changes of a process can be immediately known to other processes. However, when processing the request, the work data is copied to the context of the process. Therefore, each auxiliary process processes its own work data, and the more states the application, the larger the performance loss. Given this, careful and Wise application benchmarking is absolutely necessary.

Changes made to the <processModel> section of the configuration file take effect only after IIS is restarted. In IIS 6, parameters in Web Garden mode are stored in the IIS configuration database, and the properties of Web Garden and cpuMask are ignored.
HTTP Pipeline

After the ASP. net isapi extension starts the auxiliary process, it will pass some command line parameters. The auxiliary process uses these parameters to execute the tasks that need to be executed before the CLR is loaded. The passed values include the authentication level required for the security of COM and DCOM, the number of named pipelines that can be used, and the IIS Process Identity. The name of the named MPs queue is randomly generated using the IIS process identifier and the number of allowed MPs queues. The secondary process does not receive the name of an available MPs queue, but can receive the information required to identify the MPs queue name.

COM and DCOM Security and Microsoft®What is the relationship between. NET Framework? Actually, CLR is provided as a COM object. More accurately, CLR itself is not composed of COM code, but the interface pointing to CLR is a COM object. Therefore, the method used by the auxiliary process to load CLR is the same as that used to load COM objects.

When An ASPX request encounters IIS, the Web server assigns a token based on the selected identity authentication model (Anonymous, Windows, Basic, or Digest. When the secondary process receives the request to be processed, the token is passed to the secondary process. Requests are obtained by threads in the auxiliary process. This thread gets the identity token from the IIS thread that originally passed in the request. In aspnet_wp.exe, the actual account responsible for processing the request depends on how the simulation is configured in a special ASP. NET application. If the simulation is disabled by default), the thread runs under the account of the auxiliary process. By default, this account is ASPNET in the ASP. NET Process Model and NETWORKSERVICE in the IIS 6 process model. Both accounts are "weak" accounts and provide limited functions to effectively defend against Revert-to-self Attack attacks ). A reply attack refers to a process token that returns the Security token of the simulated client to the parent process token. Allocating a weak account to a secondary process can defeat such attacks .)

In summary, a major task completed by the ASP. NET auxiliary process is to send requests to a series of managed objects called HTTP pipelines. To activate the HTTP pipeline, you can create a new instance of the HttpRuntime class and call its ProcessRequest method. As mentioned above, ASP. NET always runs only one auxiliary process unless the Web Garden model is enabled), which manages all Web applications in an independent AppDomain. Each AppDomain has its own HttpRuntime class instance, that is, the input point in the pipeline. The HttpRuntime object initializes a series of internal objects that help implement the request. The Helper object includes the Cache object of the Cache manager) and the internal file system monitor is used to detect changes to the source files that constitute the application ). HttpRuntime creates a context for the request and fills the context with HTTP information related to the request. The context is represented by an instance of the HttpContext class.

Another Helper object created at the beginning of the HTTP runtime setting is a text writer that contains the browser's response text. The text writer is an instance of the HttpWriter class. This object caches the text sent programmatically by PAGE code. After the HTTP Runtime is initialized, it searches for the application objects that implement the request. The application object is an instance of the HttpApplication class, which is the class behind the global. asax file. Global. asax is optional for programming, but is required for building structures. Therefore, if no build class exists in the application, the default object must be used. The ASP. NET runtime contains several intermediate factory classes that can be used to find and return valid Handler objects to process requests. The first factory class used throughout the process is HttpApplicationFactory. Its main task is to use URL Information to find the matching relationship between the URL virtual directory and the collection of HttpApplication objects.

Application factory behaviors can be summarized as follows:

1. The factory class maintains the HttpApplication Object pool and uses them to process application requests. The life of the pool is the same as that of the application.
2. when the application's first request arrives, the factory class extracts information about the application type global. asax class), set the file used to monitor changes, create application status, and trigger the Application_OnStart event.
3. The factory class obtains an HttpApplication instance from the pool and puts the requests to be processed into the instance. If no available object exists, a new HttpApplication object is created. To create an HttpApplication object, you must first compile the global. asax application file.
4. HttpApplication starts to process the request, and new requests can only be processed after the request is completed. If a new request from the same resource is received, other objects in the pool are processed.
5. The application object allows all registered HTTP modules to pre-process requests and find the processing program type most suitable for processing requests. This is done by finding the extension of the requested URL and the information in the configuration file.

The HTTP handler is a class that implements the IHttpHandler interface .. NET Framework provides some predefined processing programs for common resource types, including ASPX pages and Web services. The

  1. Analysis on ASP. NET Web Security
  2. Session State of ASP. NET
  3. Analysis on the attribute ASP. NET of IsPostBack
  4. ASP. NET architecture and security mechanism
  5. Overview ASP. NET Crystal Reports

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.