Maybe AJAX Can Actually *Solve* a Problem
June 8th, 2009
Over on the Basie blog, Florian has posted an idea about using AJAX to get around one of the most annoying problems in DrProject: timeouts during lengthy batch creation of projects and/or users. Basically, his plan is to have the browser send one create request at a time, instead of sending a batch to the server and asking it to do them all at once (which often led to timeouts, since each creation can take about one second, and classes often have a hundred students or more). It’s theoretically less efficient (more network traffic, and N rewrites of the .htaccess file instead of one), but “slower and always works” is better than “faster and sometimes fails”. He’d welcome your comments…
What you can do is a compromise between this (sending n jobs) and a full batch.
Cal Henderson somewhat describes it in these slides:
http://www.slideshare.net/iamcal/scalable-web-architectures-common-patterns-and-approaches-web-20-expo-nyc-presentation
What you do is you send the entire job and return immediately with a ticket number. After that, you poll through ajax, passing your ticket number along asking for progress. The page can refresh itself through ajax with the % of work done. It’s not as hard on the server since the status can be pulled from cache (do a little work, update cache, do a little work, update cache, and only ever read from cache for the ajax request) and gives decent feedback to the user.