A company websiteProgramAfter a long period of operation, the speed slows down, and the speed becomes faster after the website is restarted. It is estimated that the memory and CPU resources occupied by the website program are not released in time, so the website needs to be restarted to release resources at intervals. However, manual restart does not always solve the problem. How can we achieve automatic management? Iis6.0's application pool automatic recycle function can solve this problem.
An application pool is a configuration that links one or more applications to one or more worker processes. Because applications in the application pool are separated from other applications by working process boundaries, applications in an application pool will not be affected by problems caused by applications in other application pools.
To configure an application pool for a web application, follow these steps: 1) Create an application pool, right-click application pool, and name it kefuapppool. 2) specify the application pool for the web application, and select kefuapppool in "application pool (n)" in "application settings" of the Web virtual directory attribute. 3) set the automatic recycle mode of the application pool. There are several recycling methods:
A. Based on the running time
The default value is 1740 minutes, that is, 29 hours. This is not a good control and is not recommended.
B. Number of requests
This depends on the specific situation. If there are only 10 requests, but five of them are requesting the page that accounts for the resources (probably the annual report statistics), the process may crash at this time, if there are 1000 requests but one page does not run, the process is certainly normal at this time, so the decision based on the number of requests may not necessarily meet the actual needs.
C. Scheduled time
This is actually good, But what time should it be recycled? Usually we set it at three o'clock AM. It is necessary to recycle it at this time, but it is not very suitable for high memory usage that may occur at any time.
D. Memory (virtual memory or used memory)
This is too suitable for the process caused by memory problems, but it is very important to set the value to a large value. The value cannot be too small, otherwise, it will be automatically reclaimed if the traffic volume is too large to exceed this value, which is unnecessary. You must observe the actual usage of the process before making a decision.
Next we will focus on the understanding of the working process to recycle the application pool.
By default, the WWW Service creates an "Overlap Recycle", that is, it continues to run the work process to be terminated until a new work process is started. In the overlapping recycling scheme, the process to be recycled continues to process requests, and the WWW Service creates an alternative working process. Start a new working process before stopping the old working process, and then direct the request to the new process. This design prevents service interruptions because the old process still maintains communication with HTTP. sys before it is closed to process requests. Because the timeout values for overlapping shutdown or startup shutdown can be configured, therefore, the worker can terminate the process while processing the request (if it has not completed the request within the time limit ).
Note: When the WWW Service recycles a working process, it does not disconnect the existing TCP/IP connection. The HTTP protocol stack (HTTP. sys) establishes and maintains TCP/IP connections.
Each application pool in IIS is managed by a "worker process", that is, the "w3wp.exe" process. If you run multiple applications in the application pool, we can see multiple w3wp.exe. As you can see in the task manager, the task manager has two w3wp.exe processes, which correspond to two application pools with applications running.
Run the iisapp-a command prompt to associate w3wp.exe with the application pool.
Shows the collection of the application pool kefuapppool manually, before, during, and after the collection. We noticed that a working process (pid = 3896) was added during the recycling process. After the working process (pid = 3896) was started, the old working process (pid = 5716) the new Working Process (pid = 3896) officially replaces the old process, which effectively prevents service interruption during application pool collection, ensures the continuous operation of the program. The PID of the Worker Process corresponding to the other two application pools is useless. This figure shows the collection process of the application pool.
The application pool is a headache for server management users. If you do not set up a website, you may go on strike at any time, or even drag down the server. This is why I came here specially.ArticleFor your reference.
In addition, if the website traffic is not very high and no one visits it at night, you can restart the server in the early morning to speed up the server and prepare for the next day's access.
The core of IIS 6 is the working process isolation mode, while the application pool defines how the working process works. Therefore, the application pool is the core of IIS 6.
Different from IIS 5, you can only use a single application pool. IIS 6, which works in work process Isolation Mode, can create multiple application pools. Different application pools are completely isolated, when an application pool stops services, it does not affect other application pools.
Before using the application pool, you should determine the number of application pools you need. Many may think that since different application pools are completely isolated, I only need to create an application pool for each web site. This method can be used when there are a small number of Web sites on the IIS server. However, if there are many web sites on the IIS server, this method is not applicable, because different application pools create their own working processes when they are accessed, a large number of working processes consume a large amount of system resources and CPU utilization when working concurrently, this reduces server performance. Based on the importance, isolation, and running of the Web siteCodeTo divide the web sites on the IIS server, and then determine the number of application pools as needed. For those very important websites, websites that need to be isolated separately, websites that run code stability and security are not reliable, they are configured to use their own independent application pool, other common web sites are configured to use a public application pool.
By default, When IIS is installed, a default website is created and an application pool named defaultapppool is created for use. The application pool under the default configuration can work well, we recommend that you configure the application pool only when necessary.
Configure application pool Properties
Expand the application pool folder in the IIS console, right-click the corresponding application pool, and click Properties. You can configure the following in the properties of the application pool:
Reclaim
In the recycle tag, you can set the recycle method of the Worker Process:
Recycle Worker Process (minutes): the number of minutes after which the worker runs to recycle the worker process. It is enabled by default and set to 1740 minutes (29 hours );
Reclaim A Worker Process (number of requests): The number of HTTP requests processed by the worker process before terminating the worker process. This is disabled by default. If it is enabled, the default value is 35000;
Recycle a worker at the following time: Recycle the worker at the specified time. disabled by default. To enable it, select the check box and click Add to add the recycle time, use 24 hours to define the time for the rollback;
When too much memory is consumed, recycle the Worker Process:
Maximum virtual memory (MB): The worker process is reclaimed when the virtual memory used by the worker process reaches the set value. The default value is 500 mb if enabled; we recommend that you set it to no more than 70% of the total virtual memory;
Maximum memory used (MB): The worker process is reclaimed when the physical memory used by the worker process reaches the set value. The default value is 192 MB if enabled; we recommend that you set it to 60% of the total physical memory size;
In addition, the application pool has the following two ways to recycle working processes, but neither of them will interrupt Web Services:
By default, application pools use overlapping collection methods. In this way, when the application pool needs to shut down a working process, a working process is created first until the new working process is successfully created;
The application pool can also shut down the old working process and then create a new working process.
If the web application does not support running multiple instances, you must configure the application pool to prohibit overlap collection. This configuration cannot be modified in the IIS console. You can only modify the disallowoverlappingrotation metabase attribute of the corresponding application pool in metabase. XML to true.
Performance
In the performance tag, you can set the running mode of the Worker Process:
When idle for this period of time, shut down the working process (minutes): How many minutes after the working process is idle, which reduces the consumption of idle working processes on system resources and CPU performance, enabled by default and set to 20 minutes;
The core Request queue is limited to (number of requests): When HTTP. when sys receives an HTTP request from a client, if the worker process of the corresponding application pool processing the request is still busy, HTTP. sys stores the received requests in the Request queue of the corresponding application pool until the worker process is idle. This option is used to set the number of requests that the request queue of this application pool can accommodate. By default, the request queue of each application pool is limited to 1000 requests, if the number exceeds 503, the system returns the 65535 error to the client. You can modify the value as needed. The maximum value is. However, setting too large will consume a lot of system resources, and setting too small will cause frequent 503 errors during client access.
Enable CPU monitoring: Monitors the CPU usage of this application pool, which is not enabled by default. If an application pool occupies too many CPU usage, you can configure this option to limit this application pool;
Maximum CPU usage (percentage): The maximum CPU usage that can be used by the Set application pool; The default value is 100 when CPU monitoring is enabled;
Refresh CPU usage (minutes ):Interval for refreshing CPU usage. The default value is 5 when CPU monitoring is enabled;
The operation performed when the CPU usage exceeds the maximum usage: When the CPU usage of the application pool exceeds the set maximum CPU usage, the default setting is none when CPU monitoring is enabled, in this case, IIS only records the event logs without performing other operations. If you choose to disable IIS, IIS will close all worker processes in the application pool;
Web Garden: in the Web garden, you can configure the maximum number of worker processes used by this application pool. The default value is 1 and the maximum value is 4000000; configuring multiple worker processes can improve the performance of the application pool to process requests. However, before you configure multiple worker processes, consider the following:
Every working process consumes system resources and CPU usage. Too many working processes will lead to a sharp consumption of system resources and CPU usage;
Each worker process has its own status data. If a web application depends on a worker process to save status data, multiple worker processes may not be supported.
Running status
In the running status tab, you can configure the application pool to monitor the running status of the worker process,
Enable Ping: by default, the application pool is configured to ping the worker process every 30 seconds. When the worker process does not respond, it is deemed that the working process has a fault and is disabled by default. You can modify the ping interval, but too Long Ping interval may cause web service interruption, and too short Ping interval will consume more system resources and CPU utilization, therefore, we recommend that you retain the default configuration;
Enable quick failure protection: if there is a problem with writing web application code, it may cause the working process to continue to have problems. By default, the application pool is configured to enable quick failure protection. When the worker process is configured for a period of time (5 minutes by default) if the number of failures in the application exceeds the configured value (5 by default), the application pool is disabled.
Start time limit: IIS waits for the start time of a worker in the application pool. When the start time of a worker exceeds the set value, IIS will record it in the event log;
Closing time limit: When IIS detects a worker process failure, it marks the worker process as disabled. This option specifies the time limit for IIS to wait for the Worker Process to automatically close, if the worker process is not closed after the time limit is exceeded, IIS forcibly closes the worker process.
Identifier
In the tag, you can configure the user account that the workflow runs. In IIS 5 or When IIS 6 runs in IIS 5 Isolation Mode, the working process runs in the local system account, IIS 6 running in work process Isolation Mode runs under the network service account, which reduces the possibility of system attacks.
You can configure a workflow to run under a predefined local system, local service, or network service account, or use a Custom User Account. We recommend that you use the default network service account. For higher security, you can configure a user account. However, we recommend that you add this user to the iis_wpg user group, therefore, the iis_wpg user group has the minimum permissions to start and run a working process.
1) Add the display PID field in the task manager; 2) Run iisapp-A at the command prompt. Note: the first running will prompt that no JS support is available. Click OK. Then run it again. In this way, you can see the application pool corresponding to the PID. As shown on the left, the application pool kefuapppoolis associated with w3wp.exeof pid1_32322. the application pool reportserverand w3wp.exe of pid1_3572are associated.