Hello fellow monks,
I'm trying to implement a FIFO non-blocking queue in a project I'm working on. What I want to do is create a queue for a pdf document to be generated. The reason I need the queue is that in the tests I've done if too many people request a pdf to be generated it bogs the server down so much only one or two people get theirs generated. The database its generated from has over a million records and some of the requested pdfs are huge. So I need to put users in line if more than one at a time requests a pdf.
What I have so far is the ability to place a user in queue and check where they are and the average time people have waited in line. The problem I'm having is figuring out how to make it non-blocking if someone decides to abandon their position in line. Currently the way I have it if someone abandons their position it will block everyone else from moving on and getting their job done.
I've never had to implement something like this before so i would appreciate any pointers on how to create something like this. I do realise that I need to have some sort of way of telling if that user who is waiting in line is still there without making the others wait unreasonably long. I was thinking of using a timestamp that updates every time a user checks their position in line.
Thanks for your help,