What I would do is set a “optimal” batch (you can vary this)
The scheduled task would call a page that processes 400 (for example). this runs every 30 seconds or minute or whatever. (a short period of time)
You can then make it self healing, so part of your query is “ok, get me the next 400 that haven’t been processed”
Part of the query of the queue can see how many are processing (start time but no end time yet) and if that is pretty high, you just exit.
Your script can have individual processing for each person etc. but the point here is that your system tracks and “self heals”
You could also add onError code in there and what not but that is another story.
So , to recap. You have a PersonQueue table, with :
id personID processingStartedDateTime processingEndedDateTime failureCount
You also have a scheduled task that runs very frequently. Your script will handle the throttling by aborting early if conditions are not met
- It does a query to find out how many items are being processed (WHERE processingStartedDateTime IS NOT NULL AND processingEndedDateTime IS NULL)
- If there are loads being processed (say 400?) Quit. you are done. Other requests are doing the work.
- If there are a lot of OLD processingStartedDateTime WHERE processingEndedDateTime is NULL AND processingStartedDateTime > RequestTimeout… then we better fix these.
- Select them, mark them as failed once (update PersonQueue SET failureCount ++) And clear the processingStartedDateTime (this request can now abort)
- the next request comes in (from the scheduled task) and sees that we have met the parameters (there aren’t too many people being processed and there aren’t a bunch that need to be cleared up) we can then:
- Get 400 people to process, set their processingStartedDateTime and get to it!
- When you have processed one person set their processingEndedDateTime
as a quick note, I would not do:
UPDATE PersonQueue SET processingStartedDateTime = #now()#
(this was a tip from Cameron Childress actually)
But rather I would set up at the top of your processing something like request.nowtime = Now() and then do:
UPDATE PersonQueue SET processingStartedDateTime = #request.nowtime#
This makes it easier to then query the items as they would all have the same start time and end time.
Does this process make more sense?
MD> On 9 Mar 2016, at 17:32, Ivan Rotrekl <@Ivan_Rotrekl> wrote:
Thanks a lot for such a quick repply !
If I understand this correctly, these are great suggestions how to monitor and track the progress of the processing.
But I am actually more confused about how to execute the processing for several thousands rows ( ideally via scheduled task ).
Lets say, I have a controller function which processes one person: process(personid) and the corresponding FW/1 url /?action=person.process&personid={personid}
-
I could write another controller function processAll() which would simply loop over query of 4000 rows and invoke process(personid). I could then call it via scheduled task, increase the request timeout & hope for the best. But that seems a bit blunt.
-
Or I could invoke via scheduled task a page or function which would call itself via cfhttp repeatedly (as I wrote in my original post). But I am not sure if that would be any better than the loop.
I could imagine a client side code which would retrieve the next personid to be processed from the server, invoke the processing, wait for it to finish and then repeat untill all done.
But I am not sure how to do it all server-side, ideally one by one. ( I would rather make 4000 relatively short-lived requests than one giant one )
Regards
Ivan
You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/cc3795e9-3a3f-4755-90b0-3095f3d907b7%40googlegroups.com https://groups.google.com/d/msgid/lucee/cc3795e9-3a3f-4755-90b0-3095f3d907b7%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.