Understanding the W3wp.exe process and fundamentally solving the problem of resource-consuming _win server

Source: Internet
Author: User
Tags exception handling
In Windows Server 2003 for each Web application, IIS 6.0 runs it with a separate w3wp.exe instance. W3wp.exe is also known as a worker process (one for each main header)

Ending a process directly in Task Manager does not work, it will start shortly after it finishes, and to end it can find the appropriate application pool in IIS to stop the corresponding application pool.

These are not the solutions, it's the fundamental problem is that your website program has a problem, before you find the problem can be turned on IIS to find the application pool first in the right key property set "performance" to the CPU set to more than 60% shut down the application pool, the shutdown time and open time to set a short period of 10 seconds, This way, when your Web site program takes up a lot of system resources, IIS automatically reclaims the process quickly and starts the process quickly, and your site can work on it for the time being.

To solve the fundamental problem, we have to start with the procedure, you can create multiple application pools in the application pool in IIS, and then, at the bottom of the file home option in each host header, apply the application pool to the application pool that you just built, and then one shutdown in Task Manager to see which program is consuming a larger resource.

Here are some of the relevant posts of netizens may be helpful to everyone


Friends of the Web server has been running normally, but these days the CPU occupancy rate has been nearly 100%, so to see what.
The server uses Windows 2003, the Web site uses the Asp+access database, and the view list of processes finds that w3wp.exe occupies more than 70% of the CPU.
View the Web log, the amount of site traffic is small, there is not much view of TCP connections. With net stop w3svc to stop the Web service, the CPU is occupied immediately normal, net start w3svc started the web soon after the phenomenon came out again. Stop all virtual sites, create a new virtual site found no problem, suspected is the site itself code problems.
Check the home code, roughly the following structure:

A rough look is not a problem, but this code caused the w3wp.exe to occupy a lot of CPU, is it a dead loop? There seems to be no reason. Add the count in the loop and find that it is really a dead loop, stating that rs.eof has been false, adding the following code:

If rs.eof = True Then Response.Write "EOF is True"
If rs.eof = False Then Response.Write "EOF is false"

Discover that the output is actually the EOF is false, which explains why the value of rs.eof cannot be judged, and why it is so baffled. Check the database, find that there is no mytable table, if the table does not exist, Rs.Open "select * FROM MyTable", conn error, why there is no error, it is possible to catch the exception was ignored.
Check the include file conn.asp and found exception handling code:

On Error Resume Next


The original question is here.

On Error Resume Next ignores the query table failure and subsequent errors, resulting in a dead loop.
Then why did the site run normally, but now can not find the MyTable table it? Carefully check the website only to find that "there are ' customers ' from afar," uploaded the backdoor tool, deleted a number of data sheets, I was busy for a day.

More content you can also go to: http://www.microsoft.com/china/technet/security/guidance/secmod93.mspx

Find more detailed security settings

Solving the problem of suspended windows2003 iis6.0

The server is always running slowly these days, and a w3wp.exe process is found to occupy the 100% CPU after telnet.

The cause of the problem was eventually found in two:

1. Problems with the use of the Jet database connection method: http://support.microsoft.com/?id=838306

Patch Download:
Chs:windowsserver2003-kb838306-x86-chs.exe
Enu:windowsserver2003-kb838306-x86-enu.exe
2. Change the Access database name extension to ASP

Here is my error process and solution:

Search to find a lot of similar problems, that w3wp process is iis6.0 application pool, the online version of two, one is because the ASP or asp.net code contains a dead loop caused. But there are so many websites on the server, who knows that the site is out of the question. The second is because the above jet connected to the database method of the bug caused by the download 838306 patch, or upgrade to SP1 can solve the problem, but after this patch, some of the site's problems still exist.


To search again, it was said that each site should be established as a separate application pool, with the application pool's security account set as Local service. The method is as follows:

First create a new application pool:
Then point the application pool for the Web site to the application pool you just created:
After all application pools have been established, the properties of the application pool are uniformly modified:
To designate an application pool security account as a local service:
After setting these up, the problem persists, such a web site is not affecting other sites, but the site still takes up a lot of resources, causing other sites to respond slowly. However, the process of each application pool appears in Task Manager, so you can find the specific problem process.

Here's the process of looking for an error site: To find this site, you have to link the problematic process to the site's application pool. First set the Task Manager to view the way to add the PID display:

Then the command line runs IISAPP-A, and you can see the relationship between the PID and the application pool:
Then go to IIS to see the application pool corresponding to the site, the problem of the site is found, the rest is the site code in the problem.

In a Web site administrator's entanglement, I finally unbearable, help him find errors-countless times to configure IIS, the Web site program also changed, the upgrade also upgraded, the problem is still there, at the end, to download the site to see what is going on. When I tried to open his database, the problem came up:

His database is an. asp extension that you want to change to. mdb before it can be opened, but when I click on the name change, my computer doesn't respond ~! Looks like the problem is in this database.

After using the command line rename, open the database, fix it, there seems to be no problem, but change to. asp, there are just the problems. Ah ~ turns out to be. asp's extension is in mischief.

But I tried to change the other database to. asp, no problem. The root cause is unknown, hope the person informed.

Finally, an ISAPI is added to the MDB in IIS, causing the MDB to not execute, prevent downloading, and change all the. asp's database back to. mdb, problem solving.

1.w3wp.exe, application, application pool relationships

An application pool can contain multiple applications, and an application pool creates a w3wp.exe process. Then we cannot simply say that an application corresponds to a w3wp.exe process!

In fact, multiple applications correspond to a w3wp.exe process.

2. How to start and close the W3wp.exe process

W3wp.exe This process will start when you access the WWW application. Someone would ask: "I started a Web application and found that the system automatically created a w3wp.exe process." But after I shut down the Web application, I found that the w3wp.exe process that I just created was still there, and how to close the process. "

This process will not shut down immediately after you close the program. That's because HTTP is connectionless access, and when you close the Web page, it won't return the appropriate shutdown information, so w3wp.exe this process will not shut down because you shut down the Web application.

So how do you close this process? In the application pool configuration, the "Idle timeout" setting is set to the appropriate time, and the system defaults to 20 minutes. Set the specified time, then no access to the application in this time range, Then the system automatically shuts down the w3wp.exe process. Without the need for us to intervene artificially.

If you have the energy, you can also end the life of the process in Windows Task Manager (^_^)!

3. How to keep the W3wp.exe process running for a long time.

W3wp.exe The default life of this process is 1740 minutes, but still in this tacit nature, w3wp.exe will be shot by the system directly after 20 minutes of unemployment.

This can be seen, in order to let w3wp.exe long life, then we can through the "idle timeout" does not deal with to achieve our goal.

This is a lot of shortcomings, but in order to achieve personal desires, this is nothing. It was not a formal project.

4. How to reduce the memory and CPU occupied by w3wp.exe

In combination with many of the online recommendations, the main solution is:

A. Separate application pool configuration for each Web site in IIS;

B. Reasonable configuration of your application pool;

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.