Design inventory management with limited time hold strategy?

by user3198603   Last Updated August 07, 2018 03:05 AM - source

Some sites, like theater ticket reservations, place a limited-time hold on the item , while the order is being processed. As soon as you select the seat and proceed to pay, Seat is reserved say for 10 minutes.

I see here a big risk where a hacker/automated script(bot)/manual user can lock all inventory and does not actually make the payment. He keeps on repeating this process. This way seats will never be booked and business will loose the revenue.

How these sites handle this scenario/challenge ?

Answers 1

I really have no idea what various sites do, but its easy enough to dream up an algorithm to make it hard for fake customers or bots.

Include a test that most AI's find difficult (like reCaptcha as Robert Harvey suggests). This should eliminate the bots.

Then a procedure something like this...

  1. Person A books item I
  2. Create provisional order for "Item I" with name/IP of person ordering.

    Request Person A to complete payment.

  3. If there are more requests for item I, while order is processing,advise customer that the item is on hold for another user and optionally place them in a queue. Discard any additional orders from person A.
  4. If person A pays on time,

    Remove item I from stock and empty the queue for that item.
    Inform queued customers that item I is sold and offer alternatives.
  5. If Person A did not pay on time.

    Go back to step 2 and start processing the next person in the queue.

If there is no demand for Item A, then who cares if mean old Person A likes to waste his time re-ordering and not paying!

August 08, 2018 00:16 AM

Related Questions

Accessing shared data without blocking in TPL

Updated June 19, 2015 12:02 PM

Data structure for concurrent look ups

Updated April 15, 2015 20:02 PM

Optimistic locking with business constraints

Updated April 25, 2018 14:05 PM