RM
Richard Metzler
Clarity Expert
How I would build this feature "take a number and go to the queue":
1. get a fast datastore central to you servers. All webservers have to look on the same central datastore, because this number has to be unique for each visitor. Redis would be perfect for this task.
2. you have to have a middleware layer in your Rails, Django or PHP setup. All HTTP-Requests have to go through this middleware layer. This middleware layer is reponsible for getting the ticket from Redis and set it as a cookie. If the browser has no cookie, it gets one. If you want to ensure that visitors can't fake the cookie, just add a secret to each cookie/ticket.
Doing this in another layer than middleware will result in bugs because you have to add the code at many different places.
3. Profit (as long as your caching etc. works and you don't get slash dotted)