[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

aspnet_wp.exe taking 100% of CPU (pls, urgent)

I've developped an application in ASP.NET, and for some reasons,  SOMETIMES (not all the time), the process hang at 100% and never release it.

Any idea what could cause this and how to solve this problem?

(I'm running XP PRO SP3, and the regular IIS coming with it.  i don't know if its v5 or 6)

Many articles say to:
- Check the IIS log (found nothing interresting.  I've joined a file to show you)
- Clean the ASP.NET temp folder
- Improve string concat http://support.microsoft.com/default.aspx?scid=kb;en-us;307340

ex090423.log
0
Christian de Bellefeuille
Asked:
Christian de Bellefeuille
  • 8
  • 5
2 Solutions
 
funwithdotnetCommented:
Sounds like an endless loop or a call to something that is not responding and never times out.

Look for a conditional loop in your code, Do While is a likely candidate. You can also step through your code in debug and see where it hangs (if it hangs.)

0
 
Christian de BellefeuilleProgrammerAuthor Commented:
I thought about that, but every loop i do are "for each", not "for i = 1 to X".

There's one loop that might be causing a problem, but even there, i analyse it, and everything look fine for me.  Plus, the problem would happen everytime i use the application because this piece of code is used everywhere.

Here's the function using a loop + recursive call, to find a specific control in a page or object:

    Private Function FindControlRecursive(ByVal root As Control, ByVal id As String) As Control
        If root Is Nothing Then
            Return Nothing
        End If
        If root.ID = id Then
            Return root
        End If
        Dim c As Control
        For Each c In root.Controls
            Dim t As Control = FindControlRecursive(c, id)
            If Not t Is Nothing Then
                Return t
            End If
        Next
        Return Nothing
    End Function

Open in new window

0
 
Christian de BellefeuilleProgrammerAuthor Commented:
Please experts, i need your help.  I've found the cause of the CPU at 100%.  This have nothing to do with my recursive call.

In my previous version, when a user was subscribing to an online-event, an email was sent to this user to confirm that he is really registered to that event.  On my computer, it was working like a charm!

On my customer web site, it was causing this error: "net_io_connectionclosed".

I've searched for a while for this error, and the solution that came to me was to add theses lines just before sending my email:

        oSmtpMail.DeliveryMethod = SmtpDeliveryMethod.Network
        oSmtpMail.Timeout = 60000
        oSmtpMail.ServicePoint.MaxIdleTime = 1

It solve the net_io_connectionclosed, but it cause the CPU to run like hell at 100%.

Any suggestion?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
funwithdotnetCommented:
Is the message delivered? If not, further investigation into the original issue,  "net_io_connectionclosed" would be advised.

If the code included above is the cause, I bet it is this line:

oSmtpMail.ServicePoint.MaxIdleTime = 1

That kills the servicepoint and after 1 ms idle time after a connection is initiated. Not enough time. Default is 100000 (100 seconds.) That might explain the 'pegging' of the CPU.
0
 
Christian de BellefeuilleProgrammerAuthor Commented:
Hi Funwithdotnet.

We can't do many tests on this server because it is highly secured and i have no access to it (I must contact the IT each time i want to place a new version online).

But this week-end i've googled a lot, and found a message in a forum saying that someone else had the same problem than us (setting maxidletime = 1 cause CPU to 100%), but with 1000 ms it was working just fine.  We have tried that, and it worked.  Of course we have to see when a bunch of user will use the system to see if it will still work or not.

I know that the default is 100 seconds.  So my guess is that when the email is sent, it keep waiting, and i reach the maximum number of connections when few users are logged in and send mail?  (because i'm using a new instance of SmtpClient for each email).

0
 
funwithdotnetCommented:
I checked on your original error. There is either a permission problem or a configuration issue. Are you using a credintial? The DefaultCrediantial will work locally but not usually on a web host.
0
 
funwithdotnetCommented:
Ok, so the original error "net_io_connectionclosed"  was fixed or no longer thrown for whatever reason? It should throw the error right away and not after a timeout of 100 sec.

For what it's worth, I set the following value to 20000. That has worked well.
oSmtpMail.Timeout = 60000
0
 
Christian de BellefeuilleProgrammerAuthor Commented:
There's no credential, the IT certified that it would work without credential.  They are doing a validation based on computer name or IP, i'm not sure.   But as i said, it was working sometime, so if it was caused by a credential problem, it would never work.

The thing is that my application send multiples emails when a user subscribed to an event (formation)
- one to himself to confirm his subscription
- one to the IT to let them know that they will need to use a security key to be able to access to this event server from outside their network.
- one to my customer who offer service similar to WebEx, to advise him that a user subscribed, but since this token key is private information and that they can't have access to it, we can't just make a CC when we are sending an email to the person who subscribed.

So 3 emails are sent in a very short period of time.  

So if 2-3 users are subscribing at the same time, and that the SmtpClient (or Smtp server itself) doesn't allow more than 2 connection at the same time, it could cause some problems.
0
 
Christian de BellefeuilleProgrammerAuthor Commented:
When we set maxidletime to 1000, there's no more net_io_connectionclosed (yet).
But when this error was thrown, it was not right away...

For now the problem seems to be solved.

I'll leave this case open for the next 3 days, but i had no emergency call from this customer since this morning, so it look good.
0
 
funwithdotnetCommented:
I see. It sounds like you have a good view of the issue.

You might consider using a loop and/or a timer to slow the process down. I doubt it would impact performance based on what you have mentioned.
0
 
Christian de BellefeuilleProgrammerAuthor Commented:
No news = Good news...

I'll close this case.  Thanks funwithdotnet
0
 
Christian de BellefeuilleProgrammerAuthor Commented:
Sorry, i thought that it would give you some points for your efforts...
I'll Accept one of your messages as the solution.
0
 
Christian de BellefeuilleProgrammerAuthor Commented:
forget my last comment, it gave you the 500 points... i guess i'm too tired :)
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now