How to deal with inventory and concurrency

早过忘川 提交于 2019-11-30 20:55:46

问题


What are strategies to deal with seemingly common scenario of a limited inventory and an order form.

If there is one item left, and two people attempt to purchase at the same time. How do you deal with whoever submits payment last?


回答1:


When a user adds a limited-supply item to their shopping cart, put a hold on the item for a small window of time - say, 15 minutes. It's theirs if they pay within the window, otherwise the hold is removed and the item is returned to the pool. (For the duration of the hold, the item considered "not available" to other users.)

AFAIK, it's pretty standard technique - I've seen Gilt do this, for instance.



来源:https://stackoverflow.com/questions/6670164/how-to-deal-with-inventory-and-concurrency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!