10 users use a javaservlet to request data.
The data can only be retrieved by the server by running a script that generally take between 1-5 minutes.
What would be the best way to implement a queuing system so that when the first user sends a request the server goes ahead and starts the script. If during that time a second and third user issues a request they are queued in the order they came in as?
What I would do is implement a Producer-Consumer pattern. You can have a queue that holds requests. A background thread waits for requests to appear on the queue. When a requests come, it picks the first one from the queue and executes it. After execution is done it checks for more requests in the queue. More requests = pop the next one execute it. No more requests = go back to sleep. The servlet should simply put the request in the queue and return back a message to the user that says "Your request is in queue. It is the Nth request in the queue, and it will approximately take T minutes". Provide another servlet that will allow the user to check the status of their request