Question

I have certain goods for consumers to buy, let's say there are 10 limited books. Users have to submit their info forms asap to get the book.

What concerns me is, if there are say 30 people submit the form, there can only be 10 people who got the book, and the other 20s will waste there time, this harms user experience.

What I want is, I store the page open count in db, if 10 people has open the page, I will stop that view. However, what if someone just close that window and don't buy? Then the remaining books will never be sold.

How can I solve this? I am wondering if I can enable the view again if someone who opened the page didn't answer for a specific time?

Was it helpful?

Solution

You might want to implement a 2-tier system.

The first tier is the count of sold books. As soon as you have sold 10 books. The action is finished and you can deactivate the view.

To prevent more users calling the url for the offer i'd recommend you some kind if AJAX Heartbeat:

  • User requests url
  • session is set for this user and comes with a timeout, in case this user doesn't to anything for X Minutes/hours/etc. If timeout is reached: session will be deleted
  • offer counter is incremented by 1
  • javascript sends a keep alive heartbeat via ajax, so your system knows that user is still using that url and hasn't moved anywhere else.
  • if the heartbeat stops: delete session and decrement offer counter by 1.

this ensures that only 10 people can look at your view at a time, but you will be able to sell all 10 books.

You might want a redirect to a different page when your counter is full?

OTHER TIPS

You can add some cookies to each user and save in database cookies values with page views information. And you can save user IP address to improve your system.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top