IIS 6.0 application Pool recycling and worker process usage Introduction _win server

Source: Internet
Author: User
Tags http request time limit cpu usage metabase

A company's web site program after a long run, slow speed, restart the site after the speed significantly faster, estimated that the Web site program occupied by the memory and CPU resources can not be released in time, only need to restart the site every time the release of resources. But manual restart is not the solution to the problem, how to achieve automatic management? The IIS6.0 application pool Automatic recycle feature solves this problem.

An application pool is a configuration that links one or more applications to one or more worker process collections. Because applications in an application pool are separated from other applications by the worker process boundaries, applications in one application pool are not affected by problems with applications in other application pools.

Configuring an application pool for a Web program requires the following steps:
1 Create an application pool, right-click "Application Pool", "New/Application Pool", named Kefuapppool;
2 Specify the application pool for the Web program, select Kefuapppool in the application pool (N) in the Web site Virtual directory attribute "application Settings";
3 The application pool automatic collection method settings. There are several ways to recycle:
A. Depending on the running time
The system defaults to 1740 minutes, that is, 29 hours, this is not very good control, recommended not.

B. Number of requests
This depends on the specific situation. If there are only 10 requests, but there are 5 of those who are requesting a page that compares resources (perhaps the annual report of statistics, and so on), this time will appear when the process is off, if the request has 1000 but one also did not run a comparison of resources of the page, this time the process is certainly very normal, Therefore, depending on the number of requests, it does not necessarily meet the actual needs.

C. Planned time
This is actually very good, but when the specific time to recycle good? Usually we are set in the early morning two three o'clock, this time the recovery is necessary, but for the presence of the possibility of a high memory footprint is not very applicable.

D. Memory (virtual memory or used memory)
This is due to the memory problem caused by the process when it is too appropriate, but set the value of how much better is a very important problem, the value can not be too small, otherwise, if the traffic is large over this value will automatically recycle, this is not necessary. Be sure to look at the actual occupancy of the process before making a decision.

The following highlights the understanding of the worker process recycling application pool.

By default, the WWW service establishes "overlapping recycle", which continues to run the worker process to terminate until a new worker process is started. In an overlapping recycle scenario, the process to be recycled continues to process the request, while the WWW service creates an alternate worker process. Start a new worker process before you stop the old worker process, and then direct the request to the new process. This design prevents service disruption because the old process still communicates with HTTP.sys to process requests before shutting down. Because the shutdown timeout value that can overlap off or start can be configured, the process can be terminated while the worker process is still processing the request (if it does not finish processing the request within the time limit).
Note : When the WWW service reclaims a worker process, it does not disconnect existing TCP/IP connections. The HTTP protocol stack (http.sys) establishes and maintains a TCP/IP connection.

Each application pool in IIS is managed by a "worker process", which is the "W3wp.exe" process. If you have programs running in multiple application pools, we can see multiple w3wp.exe. This can be seen in Task Manager, as shown in the following illustration, with two w3wp.exe processes in Task Manager that correspond exactly to two application pools where applications are running.



Run iisapp-a at a command prompt to see which application pool w3wp.exe is associated with.
The following figure shows the recycle of the application pool Kefuapppool manually, before recycling, the application pool and the worker process after recycling. We note that a work process (pid=3896) has been added to the recycling process (pid=3896), the old work process (pid=5716) is stopped, and the new worker process (pid=3896) formally replaces the old process, This prevents the service from being interrupted during application pool recycling, ensuring that the program runs continuously. The worker process PID for the other two application pools doesn't change. The diagram shows a good picture of the process of application pool recycling.


Application Pools This thing really makes Management Server people headaches, if not set up a good site at any time can strike, or even drag the server. Therefore specially find this article for everybody reference.
In addition, if the site traffic is not very large, no one at night to visit, you can try to restart the server in the morning, so you can improve the speed of the server, for the next day to prepare for the visit.
The core of IIS 6 isworker process isolation mode, and the application pool defines how the worker process works, so you can say that the application pool is the core of the entire IIS 6.
Unlike IIS 5, which can only use a single application pool, work inworker process isolation modeIIS 6 can create multiple application pools, and separate application pools are completely isolated, and an application pool stops service without impacting other application pools.
before using the application pool, you should determine the number of application pools you need。 There may be a lot of friends who think that since the different application pools are completely isolated, I just need to create an application pool for each Web site. This approach is available when there are fewer Web sites on the IIS server, but if there are many Web sites on the IIS server, this approach does not apply because different application pools create their own worker processes when they are accessed. When a large number of worker processes work concurrently, it consumes a lot of system resources and CPU utilization, but reduces server performance. You should divide the Web sites that are on the IIS server against the importance, isolation, security, and stability of the Web site, and then determine the number of application pools that are required depending on the situation. For those very important web sites, Web sites that need to be isolated separately, Web sites running code stability and insecure security are configured to use separate application pools, and other normal Web sites are configured to use a common application pool.
By default, when you install IIS, you create aDefault Web siteand create a name namedDefaultAppPoolApplication pool, the application pool under the default configuration is already working well, and it is recommended that you configure the application pool only if you need it specifically.
 
Configure application pool properties
Expand in the IIS management consoleApplication Poolfolder, and then right-click the corresponding application pool and clickProperty, you can configure the following in the properties of the application pool:
Recycle

InRecycletags, you can set up the process of the work of the recycling method:

Recycle worker process (minutes): Recycle worker process after how many minutes the worker process is running, enabled by default, and set to 1740 minutes (29 hours);
Recycle worker process (number of requests): Terminates the worker process after the worker process has processed the number of HTTP requests, which is disabled by default, and the default value is 35000if enabled;
Recycle worker processes in the following time : Recycle worker processes at specified times, disable by default, and if enabled, click Add button to add recycle time, use 24-hour system to define the time of recovery;
Recycle worker process when too much memory is consumed:
Maximum virtual memory (Mega): Reclaims worker processes when the virtual memory used by the worker process reaches the set value, which is disabled by default, and is recommended to be set to no more than 70% of the total virtual memory;
maximum memory (trillion): Reclaims worker processes when the physical memory used by the worker process reaches the set value, which is disabled by default, and if enabled, the default value is M; The recommended setting is 60% of the total physical memory;
It is also important to note that the application pool has the following two kinds of worker process recycling methods, but neither of these methods will cause disruption to the Web service:
By default, the application pool uses overlapping recycling methods. In this way, when the application pool closes a worker process, a worker process is created before the old worker process is closed until the new worker process is successfully created;
The application pool can also close the old worker process before creating a new worker process.
If the Web application does not support multiple instance runs, you must configure the application pool to prohibit overlapping recycling methods. This configuration cannot be modified in the IIS management Console and can only be done by modifying the DisallowOverlappingRotation metabase property of the corresponding application pool in MetaBase.xml.
 
 
Performance

In the Performance tab You can set how the worker process works:

close worker process after idle period (minutes): Closes this worker process after the worker process has been idle for a few minutes, which reduces the consumption of system resources and CPU performance by the idle worker process, which is enabled by default and is set to 20 minutes;
Core request queue is limited to (number of requests): When HTTP.sys receives an HTTP request sent by a client, if the worker process of the corresponding application pool that handles the request is still busy, HTTP.sys will save the received request in the corresponding application pool's request queue until the worker process is idle. This option is used to set the number of requests that the request queue for this application pool can hold, by default the request queue for each application pool is restricted to reserved1000A request, if exceed then return 503 error to the client, you can according to need to modify appropriately, the maximum can set to65535。 However, if the setting is too large, it consumes a lot of system resources, and setting too small can cause frequent 503 errors during client access.
Enable CPU monitoring: Monitors the CPU usage of this application pool, is not enabled by default, and if an application pool consumes too much CPU utilization, you can restrict this application pool by configuring this option;
Maximum CPU Usage (percentage): The maximum CPU utilization that can be used by the set of application pools, and the default value of 100 when CPU monitoring is enabled;
Refresh CPU usage (minutes): The interval between refreshing CPU usage, and the default value of 5 when CPU monitoring is enabled;
actions performed when CPU usage exceeds maximum usage: Enable CPU monitoring when the CPU usage of this application pool exceeds the maximum CPU utilization set up Shime thatNo, IIS simply records in the event log without other actions;off, IIS closes all worker processes in this application pool;
Web Garden: InWeb GardenYou can configure the maximum number of worker processes used by this application pool, the default is 1, the maximum can be set to 4000000, and the configuration using multiple worker processes can increase the performance of the application pool processing requests, but before you set up to use more than one worker process, consider the following two points:
Each worker process consumes system resources and CPU usage, and too much work processes can lead to a sharp depletion of system resources and CPU utilization;
Each worker process has its own state data, and if the Web application relies on the worker process to save state data, it may not support the use of multiple worker processes.
 
 
Operation Status

InOperation StatusTags you can configure the application pool to monitor the health of the worker process,

Enable Ping: By default, the application pool is configured to ping the worker process every 30 seconds, and when the worker process does not respond, it is considered to be a failure and is configured to close this worker process by default. You can modify the interval of the ping, but too long ping interval may cause the interruption of the Web service, and too short ping interval will consume more system resources and CPU utilization, so it is recommended that you keep the default configuration;
enable fast fail protection: If there is a problem with the Web application code writing, it may cause the worker process to continue to experience problems. By default, the application pool is configured to enable fast fail protection, which disables this application pool when the number of failures that occur within the configured time period (the default is 5 minutes) exceeds the configured value (default is 5).
Start time limit: IIS waits for the time that the worker process that belongs to this application pool to start, and when the worker process is enabled to exceed this setting, IIS records in the event log;
Shutdown time limit: When IIS detects a worker process failure, it marks the worker process as closed, which specifies the time limit for IIS to wait for the worker process to shut down automatically, and if the worker process has not been closed since the time limit is exceeded, IIS forces the worker process to shut down.
 
 
Identification

InIdentificationtab, you can configure the user account in which the worker process runs. In IIS 5 or when IIS 6 runs in IIS 5 isolation mode, the worker process runs in theLocal SystemAccount, while running in theworker process isolation modeThe worker process under IIS 6 runs in theNetwork ServicesAccount, this reduces the likelihood of the system being attacked.
You can configure the worker process to run in predefinedLocal SystemLocal ServiceOrNetwork ServicesAccount, you can also configure to use a custom user account. It is recommended that you use the defaultNetwork Servicesaccount; However, if you are using a custom user account for higher security, it is recommended that you simply add this custom user to theIIS_WPGUser group, soIIS_WPGThe user group contains the minimum permissions to start and run a worker process.

1 Add the Display PID field in Task Manager;
2 run iisapp-a at the command prompt. Note that the first run, will be prompted without JS support, click OK. And then you can run it again. This allows you to see the application pool that the PID corresponds to. As shown on the left of the previous illustration, the application pool Kefuapppool and pid=3232 w3wp.exe are associated, and the application pool ReportServer and pid=3572 are associated.

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.