July 5, 2010

how do I delay or control queries?

Question by mathew

I planning to release an Api for public. what I am looking into is since it is free I need to control the usage. there are couple of options in my mind. one is delay number of queries per second. second one is fix queries to certain number per day. but second option seems to do more work on scripting which I am planning to avoid now.

so my question is how can I delay number of queries per second limit to 2 and rest put in Queue.

I am working on php so the same script would be appreciated.

or else any other suggestions welcome

Answer by Starx

You can use php’s sleep function to hold the execution in terms of time.

$query = "....................";

// wait for 10 seconds
sleep(10);

// Then execute
$result = mysql_query($query);

//queue other queries in the same way

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!