Re: using Sleep() in server-side environment and high CPU utilization

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Egbert Nierop \(MVP for IIS\) (egbert_nierop_at_nospam.invalid)
Date: 10/16/04


Date: Sat, 16 Oct 2004 14:18:21 +0200


"Jane S" <jane_s_2004@yahoo.com> wrote in message
news:ce39d912.0410150803.780a3f2@posting.google.com...
>I have an ASP application that performs following task:
> User submits data from ASP page, ASP page calls VB6 component that
> creates a file based on user input and then calls external program
> (call it "P1") to send that file to back-end via TCP/sockets.
> Component waits for some time (about 20 sec) and checks whether output
> file was generated by external process "P1". Then component reads the
> output file, generates response for ASP page and displays that result
> to the end-user in the browser.
> While external process "P1" is working, I use Sleep() function in VB
> component to wait for file generation.

Hi,

You should never use sleep. However, sleep does not use CPU cycles, EACH
thread from the threadpool and that is not so much, SHOULD not be 'locked'
because your scalability can become nill.
It's better to use message queue for asynchronuous traffic or simply use
SOAP or use a .ASP postback request (which should included a generated key
that has been sent and should be received) which is bound to a sql server
database table (this last one might be the easiest for the moment for you).

> Webserver is Windows 2000 with IIS 5.
>
> Customer experiences high CPU utilization, system gets slow and
> eventually hangs...
>
> I was suggested that using Sleep() in server-side environment is a bad
> idea. And 20 seconds of Sleep is too long.
>
> Why is using Sleep() such a bad idea? I thought Sleep() actually
> releases CPU time for given thread letting other threads work... What
> is the reasonable time to Sleep? What alternative to Sleep() can I
> use? Remember, I need to keep browser session open to be able to
> display result to the user after output file is generated by external
> process...

There are better tricks. As above. The browser can do a 'refresh' using
jscript which checks if the transaction is complete. During the wait, an
animated gif is shown. But in no case, you should 'lock' a page while you
wait for x seconds.

> I would appreciate any help,
> Thanks a lot.



Relevant Pages

  • Re: Tuesday Morning Smokes 8/13
    ... Would you believe Wednesday Morning Smoke? ... Greets Bear, ASP. ... Back to sleep after loooong"dog walks me", ...
    (alt.smokers.pipes)
  • Re: Holiday Weekend Over Smoke
    ... Evening Bill and ASP. ... Very nice blend!! ... I got stitches and my dog wouldnt let me sleep last night. ...
    (alt.smokers.pipes)
  • Re: gmorning 5/18 smoke(s)
    ... 43, overcast in Western NY. ... For now, back to sleep. ... pipe since '62, y'all know the rest ... Good morning Ed and ASP! ...
    (alt.smokers.pipes)
  • Re: 2/15 Fri. morning smoke(s)
    ... freehand while waiting for dog to do her outdoor "thing"....juice/meds ... Back to sleep now. ... Good morning, Ed and ASP. ... It's 41F and clearing here in MidTN. ...
    (alt.smokers.pipes)
  • RE: HTML input element cannot be focused on a form generated by vbcomo
    ... Recently I have been experiencing an odd problem with an ASP page generate ... The component encapsulates a simple HTML form among other things. ... I cannot focus any of the input elements on the form ... ***I executed the same code outside of the vb6 component in a standard ASP ...
    (microsoft.public.vb.com)