Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How do I prevent more than one request (to some URL) per second with CGI?

by ehdonhon (Curate)
on Nov 27, 2002 at 21:08 UTC ( [id://216181]=note: print w/replies, xml ) Need Help??


in reply to How do I prevent more than one request (to some URL) per second with CGI?

Your main problem is going to be with race conditions. What if two different processes are started at the exact same time? Simply telling each one to sleep, as others have suggested, will not help. They will both sleep the same amount of time, then both execute at the same time.

You need a way to implement some sort of mutual exclusion lock (or semaphore). Each process would attempt to get the lock. Once a process obtains the lock, it would be the responsibility of that process to make sure it held the lock for at least one second. Each process is only allowed to execute requests while it is holding the lock.

  • Comment on Re: How do I prevent more than one request (to some URL) per second with CGI?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://216181]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found