Hi there,
I have a special situation where I need to query a service to get information for n users at a specific time each day. The problem is that if I do this all at once it will put the service offline / crash it.
So to overcome this it would be better to run this for x number of users every 10 seconds or so until x = n and then stop.
I could setup 1 cron script that runs daily and another that runs every 10 seconds. The daily script would set a value in the DB to 1 ('start query') for example (default would be 0 for off), where then the second script (run every 10 seconds) checks this database value for 1. Upon finding the setting set to true it then iterates through the users querying the service x users at a time and incrementing another column in the same DB table to keep track of where in the list it is at.
The problem with this solution (well according to me) is that the 2nd script that runs every 10secs has to query the DB each time to find out if the 'start query' setting is set to 1. This can be quite processor heavy. Does anyone have a better solution?
NB: Code is written in PHP - cannot use sleep due to max execution time of php scripts on server
I could equally do this in python, is there a max execution for limit on cgi scripts?