w3wp.exe 100% CPU

  • Thread starter Jacky via DotNetMonster.com
  • Start date
J

Jacky via DotNetMonster.com

hi everyone,
I'm developing my website with asp with IIS and 2003 server. Today when I
did some test after editing my asp script, my browser just took forever to
load the page. Then I manually closed my browser and reopen it again for
testing. But the same thing happened again after a few more tests, for which
it ended up my whole site was not responding. I found out that w3wp.exe
process took up 100% CPU usage that's why my whole site is not responding,
for which I have to restart my MSSQL server in order to work again.

I've searched around the Internet, and found out the possbile cause is my
inappropriated asp code, which leads the system runs into an infinite loop.

Now my question is I'm constantly changing my code, doing testing and
debugging all the times, so same thing may happen again (infinite loop)! If
I don't close my browser manually, and let it run until it times out, will
that free up the w3wp.exe and resume the site back to normal? Because I
don't want to restart my MSSQL server every time I have this problem cause it
will affect my clients at my website.

Please help me on this! Thanks alot!!!
 
D

David Wang [Msft]

IIS6 has several features to help with this situation.

First thing you want to do is isolate your dev environment from the
production environment. This is best done using Application Pools. Create
and use a custom Application Pool when developing your code, and let the
rest run as production.

This allows you to do the following when you screw up code that runs in
w3wp.exe -- you can now RECYCLE the custom Application Pool running your dev
code WITHOUT affecting production code running in the other Application
Pools. The recycle will kill all the misbehaving w3wp.exe of the recycled
Application Pool.

Thus, if the w3wp.exe running your dev code has an infinite loop, just
recycle your dev App Pool and things should go back to normal.

If you do not want to manually recycle, you can configure additional
CPU-monitoring health metric on the dev Application Pool to automatically
recycle the application pool after it has reached a certain CPU% over a
configurable period of time. In other words, it is possible for you to tell
IIS to automatically recycle your dev application pool if it has been 100%
CPU for one minute -- so you can just keep working and IIS6 will just
recycle automatically.

There are many other health-monitoring metrics on IIS6 that do similar
behavior, and you can experiment and take advantage of all of them on your
dev Application Pool.

The key is to first isolate your potentially badly-misbehaving dev
application in its own Application Pool. Then, you can put many IIS6
features to work for you.

--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//
hi everyone,
I'm developing my website with asp with IIS and 2003 server. Today when I
did some test after editing my asp script, my browser just took forever to
load the page. Then I manually closed my browser and reopen it again for
testing. But the same thing happened again after a few more tests, for
which
it ended up my whole site was not responding. I found out that w3wp.exe
process took up 100% CPU usage that's why my whole site is not responding,
for which I have to restart my MSSQL server in order to work again.

I've searched around the Internet, and found out the possbile cause is my
inappropriated asp code, which leads the system runs into an infinite loop.

Now my question is I'm constantly changing my code, doing testing and
debugging all the times, so same thing may happen again (infinite loop)! If
I don't close my browser manually, and let it run until it times out, will
that free up the w3wp.exe and resume the site back to normal? Because I
don't want to restart my MSSQL server every time I have this problem cause
it
will affect my clients at my website.

Please help me on this! Thanks alot!!!
 
S

S. Justin Gengo

Jacky,

You should be able to test your code on your development machine running it
as a local web site first before you deploy.

Testing before deployment should find any problems. I also would recommend
using a code checker such as the free fxcop utility for .NET found here:
http://www.gotdotnet.com/team/fxcop/ It will run through your code and alert
you to any problems it finds and give suggestions for correcting them.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Jacky via DotNetMonster.com

Thanks for the quick response! I will try it out~

So letting the browser times out instead of manually closing it before times
out will NOT solve the w3wp.exe spikes to 100% problem, am I correct?

Cause I found someone has similar problem but he/she said "When I execute som
asp code on my server, the process w3wp.exe uses 100% CPU. Then the browser
times out and the server runs normal again" Please correct me if I am wrong.
Thanks again!

Jacky


S. Justin Gengo said:
Jacky,

You should be able to test your code on your development machine running it
as a local web site first before you deploy.

Testing before deployment should find any problems. I also would recommend
using a code checker such as the free fxcop utility for .NET found here:
http://www.gotdotnet.com/team/fxcop/ It will run through your code and alert
you to any problems it finds and give suggestions for correcting them.
hi everyone,
I'm developing my website with asp with IIS and 2003 server. Today when I
[quoted text clipped - 20 lines]
Please help me on this! Thanks alot!!!
 
S

S. Justin Gengo

Jacky,

It all depends on the problem causing the spike. There are so many things
that can happen it's possible that what the other person is seeing could
happen, but be completely unrelated. In your case, if you really have
written an endless loop then the browser timing out won't help a bit.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Jacky via DotNetMonster.com said:
Thanks for the quick response! I will try it out~

So letting the browser times out instead of manually closing it before
times
out will NOT solve the w3wp.exe spikes to 100% problem, am I correct?

Cause I found someone has similar problem but he/she said "When I execute
som
asp code on my server, the process w3wp.exe uses 100% CPU. Then the
browser
times out and the server runs normal again" Please correct me if I am
wrong.
Thanks again!

Jacky


S. Justin Gengo said:
Jacky,

You should be able to test your code on your development machine running
it
as a local web site first before you deploy.

Testing before deployment should find any problems. I also would recommend
using a code checker such as the free fxcop utility for .NET found here:
http://www.gotdotnet.com/team/fxcop/ It will run through your code and
alert
you to any problems it finds and give suggestions for correcting them.
hi everyone,
I'm developing my website with asp with IIS and 2003 server. Today when
I
[quoted text clipped - 20 lines]
Please help me on this! Thanks alot!!!
 
J

Jacky L via DotNetMonster.com

Justin Gengo,

Actually I am not sure whether my revised code caused the infinite loop or
not. Can you take a look? This is the portion of code that I added to my
script and then my browser stopped responding.

sql = "select * from VisitorCount a where ID='"&Request.Form("ID")&"'"
set DataRec=DataConn.Execute(sql)
if not DataRec.eof then
Set objRecordset = Server.CreateObject("ADODB.Recordset")
objRecordset.Open "MessageLog", DataConn, adOpenStatic, adLockOptimistic
application.Lock()
objRecordset.AddNew
objRecordset.Fields("Subject") = DataRec("Subject")
objRecordset.Fields("Message") = DataRec("Message")
objRecordset2.Fields("UpdatedDate") = now
objRecordset.Update
application.UnLock()
objRecordset.close
end if
DataRec.close

Also, besides infinite loop, is there any common reason to cause w3wp.exe
process spikes 100% of CPU?

Thanks!!
Jacky



S. Justin Gengo said:
Jacky,

It all depends on the problem causing the spike. There are so many things
that can happen it's possible that what the other person is seeing could
happen, but be completely unrelated. In your case, if you really have
written an endless loop then the browser timing out won't help a bit.
Thanks for the quick response! I will try it out~
[quoted text clipped - 30 lines]
 
J

Juan T. Llibre

A quick question for you :

Why are you using ADO, instead of using ADO.NET ?
Could your problem be related to that ?




Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
==========================

Jacky L via DotNetMonster.com said:
Justin Gengo,

Actually I am not sure whether my revised code caused the infinite loop or
not. Can you take a look? This is the portion of code that I added to my
script and then my browser stopped responding.

sql = "select * from VisitorCount a where ID='"&Request.Form("ID")&"'"
set DataRec=DataConn.Execute(sql)
if not DataRec.eof then
Set objRecordset = Server.CreateObject("ADODB.Recordset")
objRecordset.Open "MessageLog", DataConn, adOpenStatic, adLockOptimistic
application.Lock()
objRecordset.AddNew
objRecordset.Fields("Subject") = DataRec("Subject")
objRecordset.Fields("Message") = DataRec("Message")
objRecordset2.Fields("UpdatedDate") = now
objRecordset.Update
application.UnLock()
objRecordset.close
end if
DataRec.close

Also, besides infinite loop, is there any common reason to cause w3wp.exe
process spikes 100% of CPU?

Thanks!!
Jacky



S. Justin Gengo said:
Jacky,

It all depends on the problem causing the spike. There are so many things
that can happen it's possible that what the other person is seeing could
happen, but be completely unrelated. In your case, if you really have
written an endless loop then the browser timing out won't help a bit.
Thanks for the quick response! I will try it out~
[quoted text clipped - 30 lines]
Please help me on this! Thanks alot!!!
 
J

Jacky L via DotNetMonster.com

Because my scripts are running ASP instead of ASP.NET. Is that anything
related? Thanks Juan!
A quick question for you :

Why are you using ADO, instead of using ADO.NET ?
Could your problem be related to that ?

Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
==========================
Justin Gengo,
[quoted text clipped - 36 lines]
 
J

Juan T. Llibre

To ask ASP questions, please post at
microsoft.public.inetserver.asp.general

This is the ASP.NET newsgroup.



Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
==========================

Jacky L via DotNetMonster.com said:
Because my scripts are running ASP instead of ASP.NET.
Is that anything related? Thanks Juan!
Juan said:
A quick question for you :

Why are you using ADO, instead of using ADO.NET ?
Could your problem be related to that ?

Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
==========================
Justin Gengo,
[quoted text clipped - 36 lines]
Please help me on this! Thanks alot!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top