Re: Does sleep increase server load?



Jason Carlton wrote:
I'm pretty sure that this is a basic question, but I simply don't know
the answer. Does the sleep command increase the server load at all
while running?

The reason I ask, I have a contact form that spam robots typically try
to use to send junk. I have some very basic filters in place that
catch 99.9% of it, which is great, but the robots still waste my
server resources in trying to utilize it. So, I was thinking of
dropping them into a loop; something along the lines of:

if ($spam_criteria eq "true") {
while (1 > 0) {
sleep 200;
}
}

else {
# send email
}

I know that the while statement would use a little of the resources,
but if sleep doesn't then the sleep 200 would at least give the server
a break in between. And when the robots attack, it's usually at a rate
of 5 or 10 per second, so this is significantly better.

But, of course, it only works if sleep 200 doesn't increase the server
load!

It won't "work" because it'll never exit the while. Calling sleep()
will tie up the process, which would be bad if you got a few thousand
requests in a short amount of time. It'd probably be best to
stop processing the message as soon as you determine $spam_criteria
is 'true'.

You could also look at many very good filters that are available,
instead of rolling your own, or using some spam aversion techniques,
like Captcha, or embedding some javasacript in your form to set
a field.
.



Relevant Pages

  • Re: context switch
    ... I wrote 2 version, one version still uses sync I/O, one server thread per ... and use same thread write back to client. ... sleep back to client programs. ... server CPU cost up to 98 too. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: context switch
    ... I wrote 2 version, one version still uses sync I/O, one server thread per ... and use same thread write back to client. ... sleep back to client programs. ... server CPU cost up to 98 too. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Windows 2003 Server MACVOL disconnect error
    ... Slect "sleep" tab ... Under Wake Options, ... '--'We have a Windows 2003 Server with a MACVOL configured to store files for 8 ... '--'because data is typically not lost when the disconnect occurs, ...
    (microsoft.public.windows.server.networking)
  • Re: SBS and suspend mode question
    ... doesn't go to sleep. ... > file/print server, no Exchange. ... > I have set the power management settings in Windows, ... > seem to obey the settings. ...
    (microsoft.public.windows.server.sbs)
  • Does sleep increase server load?
    ... I'm pretty sure that this is a basic question, ... Does the sleep command increase the server load at all ...
    (comp.lang.perl.misc)